Toggle

Toggle

A two-state button that can be either on or off.

Usage

Import the component. It's mandatory to wrap the whole component with the Tailwind tag.

const { Tailwind } = VM.require("uiisnear.near/widget/tailwind");
 
const { Toggle } = VM.require("uiisnear.near/widget/toggle");
 
if (Tailwind == undefined) return "";
<Tailwind>
  <Toggle>Toggle</Toggle>
</Tailwind>

API Reference

Toggle

The toggle.

PropTypeDefault
defaultPressed
boolean
---
pressed
boolean
---
defaultPressed
function
---
disabled
boolean
---
Data attributeValues
[data-state]"on" | "off"
[data-disabled]Present when disabled

Variants

Variants available and how to use them.

AttributeValue
variant"default" | "outline"
size"default" | "sm" | "lg"

Examples

Default

Outline

With Text

Small

Large

Disabled