Skip to content

Button

Button components are Interactive Fields (Actions) used to trigger events, submit forms, or perform custom logic defined in the form configuration.

button.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'button_basic',
kind: 'action',
type: 'button',
label: 'Click Me',
},
],
});
button.json
{
"form": [
{
"uid": "button_basic",
"kind": "action",
"type": "button",
"label": "Click Me"
}
]
}

Use these props to customize your Button component.

proptypedescription
labelstringThe text displayed inside the button (Optional if icon is present)
disabledbooleanWhether the button is interactive or not
variant'filled' | 'outlined' | 'link'Optional. Button style variant (Default: filled)
iconstringOptional CSS class for an icon (Implementation may vary by framework)
iconPosition'left' | 'right'Optional. Position of the icon relative to the label (Default: left)

Buttons support three style variants: filled (default), outlined, and link.

button-outlined.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'button_outlined',
kind: 'action',
type: 'button',
label: 'Click Me',
props: {
variant: 'outlined',
},
},
],
});
button-outlined.json
{
"form": [
{
"uid": "button_outlined",
"kind": "action",
"type": "button",
"label": "Click Me",
"props": {
"variant": "outlined"
}
}
]
}
button-link.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'button_link',
kind: 'action',
type: 'button',
label: 'Click Me',
props: {
variant: 'link',
},
},
],
});
button-link.json
{
"form": [
{
"uid": "button_link",
"kind": "action",
"type": "button",
"label": "Click Me",
"props": {
"variant": "link"
}
}
]
}

Buttons support icons that can be positioned to the left or right of the label. The label itself is optional if an icon is provided.

button-icon.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'action',
type: 'button',
label: 'Save',
props: {
icon: 'save',
},
},
],
});
button-icon.json
{
"form": [
{
"uid": "",
"kind": "action",
"type": "button",
"label": "Save",
"props": {
"icon": "save"
}
}
]
}
button-icon-right.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'action',
type: 'button',
label: 'Save',
props: {
icon: 'save',
iconPosition: 'right',
},
},
],
});
button-icon-right.json
{
"form": [
{
"uid": "",
"kind": "action",
"type": "button",
"label": "Save",
"props": {
"icon": "save",
"iconPosition": "right"
}
}
]
}
button-icon-only.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
kind: 'action',
type: 'button',
label: '',
props: {
icon: 'save',
},
},
],
});
button-icon-only.json
{
"form": [
{
"uid": "",
"kind": "action",
"type": "button",
"label": "",
"props": {
"icon": "save"
}
}
]
}

You can disable the button by setting the disabled property to true.

button.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'button_basic',
kind: 'action',
type: 'button',
label: 'Click Me',
disabled: true,
},
],
});
button.json
{
"form": [
{
"uid": "button_basic",
"kind": "action",
"type": "button",
"label": "Click Me",
"disabled": true
}
]
}

Buttons can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables and a quick description of what you will style.

CSS VariableDescription
--gui-intent-primaryBackground color of the button
--gui-intent-primary-textColor of the text inside the button
--gui-intent-primary-hoverBackground color on hover
--gui-intent-primary-activeBackground color when clicked
--gui-radius-mdBorder radius of the button

This is the anatomy of the Button Component in case you want to use your CSS styles.

button-anatomy.html
<div class="gui-widget">
<button type="button" class="gui-button" id="button_id">
Click Me
</button>
</div>