Buttons

Types

Elevated button

<Button variant="elevated">Elevated</Button>
<Button variant="elevated" disabled>Disabled</Button>

Filled button

<Button variant="filled">Filled</Button>
<Button variant="filled" disabled>Disabled</Button>

Tonal button

<Button variant="tonal">Tonal</Button>
<Button variant="tonal" disabled>Disabled</Button>

Outlined button

<Button variant="outlined">Outlined</Button>
<Button variant="outlined" disabled>Disabled</Button>

Text button

<Button variant="text">Text</Button>
<Button variant="text" disabled>Disabled</Button>

Icon

<Button>
	{#snippet start()}
		<SendIcon />
	{/snippet}
	Send
</Button>
<Button>
	{#snippet end()}
		<OpenInNewIcon />
	{/snippet}
	Open
</Button>

Size

<Button>Small</Button>
<Button --np-outlined-button-container-height="48px">Medium</Button>
<Button --np-outlined-button-container-height="56px">Large</Button>

Theming

Elevated button tokens

TokenDefault value
--np-elevated-button-container-color--np-color-surface-container-low
--np-elevated-button-container-height2.5rem
--np-elevated-button-container-shape--np-shape-corner-full
--np-elevated-button-label-text-color--np-color-on-primary

Elevated button example

<Button
	variant="elevated"
	--np-elevated-button-label-text-color="var(--np-color-tertiary)"
	--np-elevated-button-container-shape="4px"
	--np-elevated-button-container-height="48px"
>
	Custom button
</Button>

Filled button tokens

TokenDefault value
--np-filled-button-container-color--np-color-primary
--np-filled-button-container-height2.5rem
--np-filled-button-container-shape--np-shape-corner-full
--np-filled-button-label-text-color--np-color-on-primary

Filled button example


	<Button
		variant="filled"
		--np-filled-button-label-text-color="var(--np-color-on-tertiary)"
		--np-filled-button-container-color="var(--np-color-tertiary)"
		--np-filled-button-container-shape="4px"
		--np-filled-button-container-height="48px"
	>
		Custom button
	</Button>

Tonal button tokens

TokenDefault value
--np-tonal-button-container-color--np-color-secondary-container
--np-tonal-button-container-height2.5rem
--np-tonal-button-container-shape--np-shape-corner-full
--np-tonal-button-label-text-color--np-color-on-secondary-container

Tonal button example

<Button
		variant="tonal"
		--np-tonal-button-label-text-color="var(--np-color-on-tertiary-fixed)"
		--np-tonal-button-container-color="var(--np-color-tertiary-fixed)"
		--np-tonal-button-container-shape="4px"
		--np-tonal-button-container-height="48px"
	>
		Custom button
	</Button>

Outlined button tokens

TokenDefault value
--np-outlined-button-outline-color--np-color-outline
--np-outlined-button-container-height2.5rem
--np-outlined-button-container-shape--np-shape-corner-full
--np-outlined-button-label-text-color--np-color-primary

Outlined button example

<Button
	variant="outlined"
	--np-outlined-button-label-text-color="var(--np-color-tertiary)"
	--np-outlined-button-container-shape="4px"
	--np-outlined-button-container-height="48px"
>
	Custom button
</Button>

Text button tokens

TokenDefault value
--np-text-button-label-text-color--np-color-primary
--np-text-button-container-height2.5rem
--np-text-button-container-shape--np-shape-corner-full

Text button example

<Button
	variant="text"
	--np-text-button-label-text-color="var(--np-color-tertiary)"
	--np-text-button-container-shape="4px"
	--np-text-button-container-height="48px"
>
	Custom button
</Button>

API

Attributes

AttributeTypeDefaultDescription
variant'text' | 'filled' | 'outlined' | 'elevated' | 'tonal''outlined'The type of button
startSnippet | undefinedundefinedIcon at the start of the button
endSnippet | undefinedundefinedIcon at the end of the button
disabledbooleanfalseDisables the button
titlestring | null | undefinedundefinedTooltip text
...attributesHTMLButtonAttributes | HTMLAnchorAttributesUse HTMLButtonAttributes for a plain button and HTMLAnchorAttributes (automatically applied when href is set) for a link button.

Bindables

AttributeTypeDescription
elementHTMLElementA reference to the root DOM element of the component. This variable is bound using bind:this, allowing direct access to the underlying HTML element for manipulation or querying within the component's logic.