Renders a button.
Use this component when you need to perform an action such as submitting a form, confirming an action, deleting an item, toggling a setting, etc.
If you need to navigate to a different page or a specific section on the
current page and want to style the link like a button, use button_link/1
instead.
See also button_link/1
, toggle_button/1
, and disclosure_button/1
.
<.button>Confirm</.button>
<.button type=”submit”> Submit </.button>
To indicate a loading state, for example when submitting a form, use the
aria-busy
attribute:
<.button aria-label="Saving..." aria-busy>
click me
</.button>
<.button variant="primary"> primary </.button> <.button variant="secondary"> secondary </.button> <.button variant="info"> info </.button> <.button variant="success"> success </.button> <.button variant="warning"> warning </.button> <.button variant="danger"> danger </.button>
<.button size="small"> small </.button> <.button size="normal"> normal </.button> <.button size="medium"> medium </.button> <.button size="large"> large </.button>
<.button fill="solid"> solid </.button> <.button fill="outline"> outline </.button> <.button fill="text"> text </.button>
<.button shape={nil}> nil </.button> <.button shape="circle"> circle </.button> <.button shape="pill"> pill </.button>