Playground
function onClick() {
console.log('clicked');
}
<GoAButton onClick={onClick}>
Primary Button
</GoAButton>
Properties
type
primary | submit | secondary | tertiary | start
Sets the type of button.
Defaults to
Defaults to
primary
.size
normal | compact
Sets the size of button.
Defaults to
Defaults to
normal
.variant
normal | destructive
Styles the button to show a destructive action.
Defaults to
Defaults to
normal
.disabled
boolean
Disables the button.
Defaults to
Defaults to
false
.leadingIcon
GoAIconType
Shows an icon to the left of the text.
trailingIcon
GoAIconType
Shows an icon to the right of the text.
width
string
Sets the width of the button.
onClick
(e: any) => void
Callback function when button is clicked.
testId
string
Sets the data-testid attribute. Used with ByTestId queries in tests.
mt,mr,mb,ml
none | 3xs | 2xs | xs | s | m | l | xl | 2xl | 3xl | 4xl
Apply margin to the top, right, bottom, and/or left of the component.
<GoAText size="heading-l" mb="xl">
What is your address?
</GoAText>
<GoABlock gap="xl" direction="column">
<GoAFormItem label="Street Address">
<GoAInput name="address" type="text" value="" onChange={onChange} width="100%"></GoAInput>
</GoAFormItem>
<GoAFormItem label="Suite or unit #">
<GoAInput name="suite" type="text" value="" onChange={onChange} width="100%"></GoAInput>
</GoAFormItem>
<GoAFormItem label="City or town">
<GoAInput name="city" type="text" value="" onChange={onChange} width="100%"></GoAInput>
</GoAFormItem>
<GoABlock direction="row" gap="xl">
<GoAFormItem label="Provice or territory">
<GoADropdown onChange={onChange} name="province" value="alberta">
<GoADropdownItem label="Alberta" value="alberta"></GoADropdownItem>
<GoADropdownItem label="British Columbia" value="bc"></GoADropdownItem>
<GoADropdownItem label="Manitoba" value="manitoba"></GoADropdownItem>
<GoADropdownItem label="New Brunswick" value="new-brunswick"></GoADropdownItem>
<GoADropdownItem label="Newfoundland and Labrador" value="newfoundland"></GoADropdownItem>
<GoADropdownItem label="Nova Scotia" value="nova-scotia"></GoADropdownItem>
<GoADropdownItem label="Ontario" value="ontario"></GoADropdownItem>
<GoADropdownItem label="Prince Edward Island" value="prince-edward-island"></GoADropdownItem>
<GoADropdownItem label="Quebec" value="quebec"></GoADropdownItem>
<GoADropdownItem label="Saskatchewan" value="saskatchewan"></GoADropdownItem>
</GoADropdown>
</GoAFormItem>
<GoAFormItem label="Postal Code">
<GoAInput name="postalCode" type="text" value="" onChange={onChange} width="7ch"></GoAInput>
</GoAFormItem>
</GoABlock>
</GoABlock>
<GoAButtonGroup alignment="start" mt="2xl">
<GoAButton type="primary" onClick={onClick}>
Save and continue
</GoAButton>
<GoAButton type="secondary" onClick={onClick}>
Cancel
</GoAButton>
</GoAButtonGroup>
Are you sure you want to delete this record?
This action cannot be undone.
const [open, setOpen] = useState(false);
<GoAButton type="tertiary" leadingIcon="trash" onClick={() => setOpen(true)}>Delete record</GoAButton>
<GoAModal
heading="Are you sure you want to delete this record?"
open={open}
role="alertdialog"
onClose={() => setOpen(false)}
actions={
<GoAButtonGroup alignment="end">
<GoAButton type="tertiary" onClick={() => setOpen(false)}>
Cancel
</GoAButton>
<GoAButton type="primary" variant="destructive" onClick={() => setOpen(false)}>
Delete record
</GoAButton>
</GoAButtonGroup>
}
>
<p>This action cannot be undone.</p>
</GoAModal>
Disabled button with a required field
function onClick() {
// do nothing.
}
onChange(name: string, value: string) {}
<form>
<GoAFormItem label="Name" requirement="required">
<GoAInput name="input" type="text" onChange={onChange} width="100%"></GoAInput>
</GoAFormItem>
<GoAButtonGroup alignment="start" mt="l">
<GoAButton disabled={true} onClick={onClick}>
Confirm
</GoAButton>
<GoAButton type="secondary" onClick={onClick}>
Cancel
</GoAButton>
</GoAButtonGroup>
</form>
Book time in drop in hours