Button
Basic button, with optional icon.
Props
- label (string): Button content. Supports light markdown.
- [OPTIONAL] id (string):
id
HTML attribute to set to the element. - [OPTIONAL] type (
button
|submit
):type
HTML attribute to set to the element. Defaults to"button"
. - [OPTIONAL] iconPosition (
left
|right
): Position of the icon relatively to the label. Defaults to"left"
. - [OPTIONAL] icon (string): Name of the icon to set to the element.
- [OPTIONAL] modifiers (string): List of modifiers to apply to the element. Defaults to
""
. - [OPTIONAL] disabled (boolean): When element is disabled, a special
disabled
modifier is automatically added, and all its user interactions are disabled. Defaults tofalse
.
Events
- click (event: MouseEvent) => void: HTML
click
event handler. - focus (event: FocusEvent) => void: HTML
focus
event handler.
Syntax - label only
- React
- Vue
- Svelte
- HTML
<UIButton
id="my-id"
type="submit"
label="Lorem ipsum"
modifiers="large primary"
onClick={myClickHandler}
onFocus={myFocusHandler}
/>
<UIButton
id="my-id"
type="submit"
label="Lorem ipsum"
modifiers="large primary"
:onClick="myClickHandler"
:onFocus="myFocusHandler"
/>
<UIButton
id="my-id"
type="submit"
label="Lorem ipsum"
modifiers="large primary"
onClick={myClickHandler}
onFocus={myFocusHandler}
/>
<button
id="my-id"
type="submit"
tabindex="0"
class="ui-button ui-button--large--primary"
>
<span class="ui-button__label">
Lorem ipsum
</span>
</button>
Syntax - label with left icon
- React
- Vue
- Svelte
- HTML
<UIButton
icon="star"
iconPosition="left"
label="Lorem ipsum"
/>
<UIButton
icon="star"
icon-position="left"
label="Lorem ipsum"
/>
<UIButton
icon="star"
iconPosition="left"
label="Lorem ipsum"
/>
<button
class="ui-button"
tabindex="0"
type="button"
>
<i class="ui-button__icon">
star
</i>
<span class="ui-button__label">
Lorem ipsum
</span>
</button>
Syntax - label with right icon
- React
- Vue
- Svelte
- HTML
<UIButton
icon="star"
iconPosition="right"
label="Lorem ipsum"
/>
<UIButton
icon="star"
icon-position="right"
label="Lorem ipsum"
/>
<UIButton
icon="star"
icon-position="right"
label="Lorem ipsum"
/>
<button
tabindex="0"
type="button"
class="ui-button"
>
<span class="ui-button__label">
Lorem ipsum
</span>
<i class="ui-button__icon">
star
</i>
</button>
Syntax - icon only
- React
- Vue
- Svelte
- HTML
<UIButton
icon="star"
/>
<UIButton
icon="star"
/>
<UIButton
icon="star"
/>
<button
tabindex="0"
type="button"
class="ui-button ui-button--icon"
>
<i class="ui-button__icon">
star
</i>
</button>
Syntax - disabled
- React
- Vue
- Svelte
- HTML
<UIButton
disabled
label="Lorem ipsum"
/>
<UIButton
disabled
label="Lorem ipsum"
/>
<UIButton
disabled
label="Lorem ipsum"
/>
<button
tabindex="-1"
type="button"
class="ui-button ui-button--disabled"
>
<span class="ui-button__label">
Lorem ipsum
</span>
</button>