Button
Last updated
Last updated
© 2024 UI Bakery
Button is a simple yet functional component that allows you to call actions, add navigation options, etc. Buttons can be used as standalone components, or as building blocks in another component, e.g. a modal.
Method | Description |
---|---|
Triggers allow you to launch certain actions based on different events.
Buttons are used to call for certain actions. Let's check the case of adding a button that will remove the employee from the employees' list.
Start with adding a button to the working area. You can customize the button as you need, e.g. change its color, and style (filled, outline, or ghost) and add an icon.
2. Navigate the Triggers tab and select On Click trigger. Click Add new action to create an action that will remove the information about a selected employee.
3. Configure an action that will delete the employee:
You might need to hide a button from the users based on a certain condition, e.g. a user's role. Let's say you have an employees list, and you would like to show the Approve promotion button to an HR department only. Here's how to do that:
Add a button to the working area and rename it as required, e.g. Approve promotion.
Click the button to open its settings. Navigate the Condition field.
In the condition field, specify the required condition, e.g. {{user.role == 'hr'}}
To manage the button once it's been hidden, navigate the App structure tab in the left menu, and find it in the components list:
The buttons can be disabled based on a certain condition. Let's review the case when you have an Activate button available only for the employees who have a "not active" status on the employees' list.
Add a button and rename it as required, e.g. Activate.
Click the button to open its settings. Navigate the Disabled field.
Click Yes and switch to JS to set the condition.
Specify the code using the following pattern: {{ui.employeesDetail.value.status == 'active'}}
To add navigation using a button, follow this guide:
You might also be interested in using a button inside the table:
click()
calls for a button click and triggers an assigned action
setDisabled(disabled: boolean)
sets button's state (enabled/disabled)
setURL(url: string)
sets the navigation URL
On Click
Calls for an action when you click a button
On Init
Calls for an action on component initialization, e.g., page refresh