Button class
A clickable button component, used for actions in forms, dialogs, and more.
It can be rendered using different HTML tags (defaulting to <button>) and
styled with a variety of modifiers for color, size, shape, and state.
- Inheritance
-
- Object
- UiComponent
- Button
Constructors
-
Button(List<
Component> ? children, {String tag = 'button', ButtonHtmlType? htmlType, String? role, bool isNativeSubmit = false, List<ButtonStyling> ? style, String? id, String? classes, Styles? css, Map<String, String> ? attributes, Map<String, List< ? eventHandlers, UiMouseEventHandler? onClick, Component? child, Key? key})UiEventHandler> > -
Creates a Button component.
const
Properties
- baseClass → String
-
Gets the base CSS class for this component (e.g., "btn" for a button).
no setter
- child → Component?
-
A single child component to be rendered.
Mutually exclusive with children.
finalinherited
-
children
→ List<
Component> ? -
The list of child components to be rendered within this component.
Mutually exclusive with child.
finalinherited
- classes → String?
-
A string of additional, space-separated CSS classes to apply directly.
This is an escape hatch for utilities not yet abstracted by
deepyror for applying styles to primitive Jaspr components.finalinherited - combinedClasses → String
-
Computes the combined string of CSS classes to be applied to the component's root element.
no setterinherited
-
componentAttributes
→ Map<
String, String> -
Gets the final map of HTML attributes for the component.
no setterinherited
- css → Styles?
-
A Jaspr
Stylesobject for applying inline CSS to the root element.finalinherited -
eventHandlers
→ Map<
String, List< UiEventHandler> > -
A map for custom or less common event handlers.
The key is the event name (e.g., "focus", "blur"), and the value is a list of handlers.
finalinherited
-
eventMap
→ Map<
String, EventCallback> -
Constructs the map of event handlers for the underlying
DomComponent.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- htmlType → ButtonHtmlType?
-
The HTML 'type' attribute for the button.
If the tag is 'button' and htmlType is null, it defaults to
ButtonHtmlType.button.final - id → String?
-
The HTML
idfor the root element.finalinherited - isNativeSubmit → bool
-
If true, this button will render as a primitive element to allow native
browser form submission behavior, bypassing Jaspr's
preventDefault. This is essential for closing<dialog>elements with<form method="dialog">.final - key → Key?
-
Controls how one component replaces another component in the tree.
finalinherited
- onChange → UiInputEventHandler?
-
finalinherited
- onClick → UiMouseEventHandler?
-
finalinherited
- onInput → UiInputEventHandler?
-
finalinherited
- onKeyDown → UiKeyboardEventHandler?
-
finalinherited
- onKeyUp → UiKeyboardEventHandler?
-
finalinherited
- onMouseEnter → UiMouseEventHandler?
-
finalinherited
- onMouseLeave → UiMouseEventHandler?
-
finalinherited
- role → String?
-
The ARIA role for the component.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
style
→ List<
Styling> ? -
A list of type-safe
Stylinginstances (general or component-specific utility classes) to apply for styling.finalinherited - tag → String
-
The HTML tag for the root element of this component (e.g., "div", "button").
finalinherited
-
userProvidedAttributes
→ Map<
String, String> -
Gets the attributes directly provided by the user when the component was instantiated.
Returns an empty map if no attributes were provided.
no setterinherited
Methods
-
build(
BuildContext context) → Component -
Describes the part of the user interface represented by this component.
override
-
configureAttributes(
UiComponentAttributes attributes) → void -
Configures component-specific HTML attributes.
override
-
copyWith(
{String? id, String? classes, Styles? css, Map< String, String> ? attributes, Map<String, List< ? eventHandlers, Key? key, bool? isNativeSubmit}) → ButtonUiEventHandler> > -
An abstract method that concrete components must implement to create a copy
of themselves with new values.
override
-
createElement(
) → Element -
Creates a
StatelessElementto manage this component's location in the tree.inherited -
mergeClasses(
String? originalClasses, String? newClasses) → String? -
Merges two CSS class strings, safely handling null or empty inputs.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
shouldRebuild(
covariant Component newComponent) → bool -
Implement this method to determine whether a rebuild can be skipped.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- accent → const ButtonStyle
-
Accent button style.
btn-accent - active → const ButtonStyle
-
Active button style.
btn-active - block → const ButtonStyle
-
Block level button style (takes full width of its parent).
btn-block - circle → const ButtonStyle
-
Circle button shape.
btn-circle - dash → const ButtonStyle
-
Dash button style.
btn-dash - disabled → const ButtonStyle
-
Disabled button style.
btn-disabled - error → const ButtonStyle
-
Error button style.
btn-error - ghost → const ButtonStyle
-
Ghost button style.
btn-ghost - info → const ButtonStyle
-
Info button style.
btn-info - lg → const ButtonStyle
-
Large button size.
btn-lg - link → const ButtonStyle
-
Link button style.
btn-link - md → const ButtonStyle
-
Medium button size (default).
btn-md - neutral → const ButtonStyle
-
Neutral button style.
btn-neutral - outline → const ButtonStyle
-
Outline button style.
btn-outline - primary → const ButtonStyle
-
Primary button style.
btn-primary - secondary → const ButtonStyle
-
Secondary button style.
btn-secondary - sm → const ButtonStyle
-
Small button size.
btn-sm - soft → const ButtonStyle
-
Soft button style.
btn-soft - square → const ButtonStyle
-
Square button shape.
btn-square - success → const ButtonStyle
-
Success button style.
btn-success - warning → const ButtonStyle
-
Warning button style.
btn-warning - wide → const ButtonStyle
-
Wide button style (takes more horizontal space).
btn-wide - xl → const ButtonStyle
-
Extra large button size.
btn-xl - xs → const ButtonStyle
-
Extra small button size.
btn-xs