Work in Progress

This library is still a work in progress and things will likely change.

Nova by Resknow

Button

Component UI

Included with Starter Kit

Preview

Button

More information

This component is available with our Astro Starter Kit.

Usage

Import the component on the page or component you need, like this:

---
import Button from '@components/Button.astro';
---

If you pass an href prop, buttons are rendered as links. Otherwise, they are rendered as a button element.

<Button href="/contact/">Contact Us</Button>

Button

<Button type="button" x-on:click="isOpen = true">
	Open Menu
</Button>

Submit Button

<Button type="submit">Send</Button>

Reset Button

<Button type="reset" variant="secondary">
	Cancel
</Button>

Available Props

variant

This sets the visual style of the button, usually the colours. By default, primary and secondary are valid options, with primary being implied if you don’t specify.

size

This sets the size of the button. By default, sm, md and lg are valid options, with md being implied if you don’t specify.

href

Sets the href attribute on a link. Setting this will cause the button to render as a link.

type

The button type. Valid HTML button types are valid here. (button, submit, reset)

Icon

You can pass in an icon in one of 2 available slots. These are start and end. For example:

<Button href="/contact/">
	Get Started
	<Icon name="arrow-right" slot="end" />
</Button>

Notice the slot prop on the Icon. This tells the Button to place the icon after the text.

<Button href="/contact/">
	Get Started
	<Icon name="arrow-right" slot="start" />
</Button>

In this example, we tell the Button to place the icon before the text, at the start. It doesn’t matter where the icon is, so you can move it before the text if you prefer.

These examples use the Icon component. This isn’t required but makes life easier when dealing with SVG icons.