Element classes | laravel-html | Spatie

 SPATIE

  Laravel HTML
===============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-html](https://spatie.be/docs/laravel-html/v3)  General-usage  Element classes

 Version   v3   v2   v1

 Other versions for crawler [v3](https://spatie.be/docs/laravel-html/v3) [v2](https://spatie.be/docs/laravel-html/v2) [v1](https://spatie.be/docs/laravel-html/v1)

  Element classes
- [ Introduction ](https://spatie.be/docs/laravel-html/v3/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-html/v3/postcardware)
- [ Installation &amp; setup in Laravel ](https://spatie.be/docs/laravel-html/v3/installation-setup)
- [ Upgrading ](https://spatie.be/docs/laravel-html/v3/upgrading)
- [ Questions and issues ](https://spatie.be/docs/laravel-html/v3/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-html/v3/changelog)

General usage
-------------

- [ Core concepts ](https://spatie.be/docs/laravel-html/v3/general-usage/core-concepts)
- [ Extending the package ](https://spatie.be/docs/laravel-html/v3/general-usage/extending)
- [ HTML builder ](https://spatie.be/docs/laravel-html/v3/general-usage/html-builder)
- [ Element classes ](https://spatie.be/docs/laravel-html/v3/general-usage/element-classes)
- [ Element methods ](https://spatie.be/docs/laravel-html/v3/general-usage/element-methods)
- [ The class() helper ](https://spatie.be/docs/laravel-html/v3/general-usage/the-class-helper)

 Element classes
===============

###  On this page

1. [ Generic ](#content-generic-element)

This package includes some element classes out of the box, others can be created using the [generic `Spatie\Html\Elements\Element` class](#generic-codeelementcode).

All elements can use the [base element methods](/laravel-html/general-usage/element-methods). Some elements also have some element specific methods to easily set common attributes. These element specific methods can be found bellow.

Generic `Element`
-------------------------------------------------------------------------------------------------------

Any HTML element can be created from the generic `Spatie\Html\Elements\Element` class via the `withTag` method.

For example to create a `` tag:

```
echo Element::withTag('p')->text('This is the content!');
// "This is the content!"
```

`A`
-------------------------------------------------------------

- `function href(?string $href)`
- `function target(string $target)`

`Button`
----------------------------------------------------------------------------

- `function disabled($disabled = true)`
- `function name(?string $name)`
- `function type(?string $type)`
- `function value(?string $value)`

`Div`
-------------------------------------------------------------------

`Fieldset`
----------------------------------------------------------------------------------

- `function disabled($disabled = true)`
- `function legend(?string $contents)`

`File`
----------------------------------------------------------------------

- `function accept(?string $value)`
- `function acceptAudio()`
- `function acceptImage()`
- `function acceptVideo()`
- `function autofocus(?$autofocus)`
- `function multiple()`
- `function name(?string $name)`
- `function required()`

`Form`
----------------------------------------------------------------------

- `function acceptsFiles()`
- `function action(?string $action)`
- `function autocomplete(bool|string $autocomplete = true)`
- `function method(?string $method)`
- `function name(?string $name)`
- `function novalidate($novalidate = true)`
- `function target(string $target)`

`I`
-------------------------------------------------------------

`Img`
-------------------------------------------------------------------

- `function alt(?string $alt)`
- `function src(?string $src)`

`Input`
-------------------------------------------------------------------------

- `function autocomplete(bool|string $autocomplete = true)`
- `function autofocus(?$autofocus)`
- `function checked($checked = true)`
- `function disabled($disabled = true)`
- `function isReadonly($readonly = true)`
- `function maxlength(int $maxlength)`
- `function minlength(int $minlength)`
- `function name(?string $name)`
- `function placeholder(?string $placeholder)`
- `function required($required = true)`
- `function size($size)`
- `function type(?string $type)`
- `function unchecked()`
- `function value(?string $value)`

`Label`
-------------------------------------------------------------------------

- `function for(?string $for)`

`Legend`
----------------------------------------------------------------------------

`Optgroup`
----------------------------------------------------------------------------------

- `function disabled($disabled = true)`
- `function label(?string $label)`

`Option`
----------------------------------------------------------------------------

- `function disabled($disabled = true)`
- `function selected()`
- `function selectedIf(bool $condition)`
- `function unselected()`
- `function value(?string $value)`

`P`
-------------------------------------------------------------

`Select`
----------------------------------------------------------------------------

- `function autocomplete(bool|string $autocomplete = true)`
- `function autofocus(?$autofocus)`
- `function disabled(?$disabled)`
- `function isReadonly(?$readonly)`
- `function multiple()`
- `function name(?string $name)`
- `function optgroup(string $label, iterable $options)`
- `function options(iterable $options)`
- `function placeholder(?$text)`
- `function required(?$required)`
- `function value(?string $value)`

`Span`
----------------------------------------------------------------------

`Textarea`
----------------------------------------------------------------------------------

- `function autocomplete(bool|string $autocomplete = true)`
- `function autofocus()`
- `function cols(int $cols)`
- `function disabled(?$disabled)`
- `function isReadonly(?$readonly)`
- `function maxlength(int $maxlength)`
- `function minlength(int $minlength)`
- `function name(?string $name)`
- `function placeholder(?string $placeholder)`
- `function required()`
- `function required(?$required)`
- `function rows(int $rows)`
- `function value(?string $value)`

 A good
match?
-------------

### What we do best

- All things Laravel
- Custom frontend components
- Building APIs
- AI-powered features
- Simplifying things
- Clean solutions
- Integrating services

### Not our cup of tea

- WordPress themes
- Cutting corners
- Free mockups to win a job
- "Just execute the briefing"

 In short: we'd like to be a **substantial part** of your project.

 [ Get in touch via email ](mailto:info@spatie.be?subject=A%20good%20match%21&body=Tell%20us%20as%20much%20as%20you%20can%20about%0A-%20your%20online%20project%0A-%20your%20planning%0A-%20your%20budget%0A-%20%E2%80%A6%0A%0AAnything%20that%20helps%20us%20to%20start%20straightforward%21)
