View as Markdown
Label
A text element that identifies form controls and other content.
Loading...
<div>
<twig:Label for="text">Company</twig:Label>
<twig:Input id="text" type="text" />
</div>
Installation
php bin/console ux:install label --kit flowbite-4
Install the following Composer dependencies:
composer require twig/extra-bundle twig/html-extra:^3.12.0 tales-from-a-dev/twig-tailwind-extra:^1.0.0
Copy the following file(s) into your app:
{# @prop variant 'default'|'invalid' The visual style variant. #}
{# @block content The label text for a form control. #}
{%- props variant = 'default' -%}
{%- set style = html_cva(
base: 'block text-sm font-medium',
variants: {
variant: {
default: 'text-heading',
invalid: 'text-fg-danger-strong',
},
},
) -%}
<label
class="{{ style.apply({variant: variant}, attributes.render('class'))|tailwind_merge }}"
{{ attributes }}
>
{%- block content %}{% endblock -%}
</label>
Usage
<twig:Label for="email">Your email address</twig:Label>
API Reference
<twig:Label>
| Prop | Type | Default |
|---|---|---|
variant The visual style variant.
|
'default'|'invalid' |
'default' |
| Block | Description |
|---|---|
content |
The label text for a form control. |