Rust shadcn/ui Logo

Introduction

Rust shadcn/ui is a Rust port of shadcn/ui.

shadcn/ui is a library of beautifully designed components that you can copy and paste into your apps.

Frameworks

Rust shadcn/ui is available for the following frameworks:

The following frameworks are under consideration:

The tables below show the support for the various frameworks.

  • ✅ = Supported
  • 🟦 = Early Support
  • 🚧 = Work In Progress
  • ❌ = Unsupported

Primitives Support

NameDioxusLeptosYew
Accordion#12#61#110
Alert#13#62🟦 #111
Alert Dialog#14#63#112
Aspect Ratio#15#64🟦 #113
Avatar#16#65🟦 #114
Badge#17#66🟦 #115
Breadcrumb#18#67🟦 #116
Button#19🚧 #68🟦 #117
Calendar#20#69#118
Card#21#70🟦 #119
Carousel#22#71#120
Chart#23#72#121
Checkbox#24#73#122
Collapsible#25#74#123
Combobox#26#75#124
Command#27#76#125
Context Menu#28#77#126
Data Table#29#78#127
Date Picker#30#79#128
Dialog#31#80#129
Drawer#32#81#130
Dropdown Menu#33#82#131
Form#34#83#132
Hover Card#35#84#133
Input#36#85🟦 #134
Input OTP#37#86#135
Label#38#87🟦 #136
Menubar#39#88#137
Navigation Menu#40#89#138
Pagination#41#90🟦 #139
Popover#42#91#140
Progress#43#92#141
Radio Group#44#93#142
Resizable#45#94#143
Scroll Area#46#95#144
Select#47#96#145
Separator#48#97🟦 #146
Sheet#49#98#147
Skeleton#50#99🟦 #148
Slider#51#100#149
Sonner#52#101#150
Switch#53#102🟦 #151
Table#54#103🟦 #152
Tabs#55#104#153
Textarea#56#105🟦 #154
Toast#57#106#155
Toggle#58#107#156
Toggle Group#59#108#157
Tooltip#60#109#158
Total0 / 491 / 4915 / 49

License

This project is available under the MIT license.

Rust For Web

The Rust shadcn/ui project is part of the Rust For Web.

Rust For Web creates and ports web UI libraries for Rust. All projects are free and open source.

Getting Started

Components

Alert

Displays a callout for user attention.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add alert

Usage

use yew::prelude::*;

use crate::components::ui::alert::{Alert, AlertDescription, AlertTitle};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Alert>
            <Terminal class="h-4 w-4" />
            <AlertTitle>{"Heads up!"}</AlertTitle>
            <AlertDescription>
                {"You can add components and dependencies to your app using the cli."}
            </AlertDescription>
        </Alert>
    }
}

Examples

Default

Destructive

See Also

Aspect Ratio

Displays content within a desired ratio.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add aspect-ratio

Usage

use yew::prelude::*;

use crate::components::ui::aspect_ratio::AspectRatio;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <div class="w-[450px]">
            <AspectRatio ratio={16.0 / 9.0}>
                <img src="..." alt="Image" class="rounded-md object-cover" />
            </AspectRatio>
        </div>
    }
}

See Also

Avatar

An image element with a fallback for representing the user.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add avatar

Usage

use yew::prelude::*;

use crate::components::ui::avatar::{Avatar, AvatarFallback, AvatarImage};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Avatar>
            <AvatarImage src="https://github.com/shadcn.png" />
            <AvatarFallback>{"CN"}</AvatarFallback>
        </Avatar>
    }
}

See Also

Badge

Displays a badge or a component that looks like a badge.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add badge

Usage

use yew::prelude::*;

use crate::components::ui::badge::{Badge, BadgeVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Badge variant={BadgeVariant::Outline}>{"Badge"}>/Badge>
    }
}

You can use the BadgeVariant helper to create a link that looks like a badge.

use yew::prelude::*;
use yew_router::prelude::*;

use crate::components::ui::badge::{Badge, BadgeClass, BadgeVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Link class={BadgeClass::builder().variant(BadgeVariant::Outline).build().to_class()}>
            {"Badge"}
        </Link>
    }
}

Examples

Default

Secondary

Outline

Destructive

See Also

Breadcrumb

Displays the path to the current resource using a hierarchy of links.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add breadcrumb

Usage

use yew::prelude::*;

use crate::components::ui::badge::{Badge, BadgeVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Breadcrumb>
            <BreadcrumbList>
                <BreadcrumbItem>
                    <BreadcrumbLink href="/">{"Home"}</BreadcrumbLink>
                </BreadcrumbItem>
                <BreadcrumbSeparator />
                <BreadcrumbItem>
                    <BreadcrumbLink href="/components">{"Components"}</BreadcrumbLink>
                </BreadcrumbItem>
                <BreadcrumbSeparator />
                <BreadcrumbItem>
                    <BreadcrumbPage>{"Breadcrumb"}</BreadcrumbPage>
                </BreadcrumbItem>
            </BreadcrumbList>
        </Breadcrumb>
    }
}

Examples

Custom Separator

Use a custom component as children for <BreadcrumbSeparator /> to create a custom separator.

You can compose <BreadcrumbItem /> with a <DropdownMenu /> to create a dropdown in the breadcrumb.

Collapsed

A <BreadcrumbEllipsis /> component is provided to show a collapsed state when the breadcrumb is too long.

To use a custom link component from your routing library, you can use the as_child prop on <BreadcrumbLink />.

Responsive

Here's an example of a responsive breadcrumb that composes <BreadcrumbItem /> with <BreadcrumbEllipsis />, <DropdownMenu />, and <Drawer />.

It displays a dropdown on desktop and a drawer on mobile.

See Also

Button

Displays a button or a component that looks like a button.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add button

Usage

use yew::prelude::*;

use crate::components::ui::button::{Button, ButtonVariant};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Button variant={ButtonVariant::Outline}>{"Button"}>/Button>
    }
}

Examples

Primary

Secondary

Destructive

Outline

Ghost

Icon

With Icon

Loading

As Child

See Also

Card

Displays a card with header, content, and footer.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add card

Usage

use yew::prelude::*;

use crate::components::ui::card::{
    Card,
    CardContent,
    CardDescription,
    CardFooter,
    CardHeader,
    CardTitle,
};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Card>
            <CardHeader>
                <CardTitle>{"Card Title"}</CardTitle>
                <CardDescription>{"Card Description"}</CardDescription>
            </CardHeader>
            <CardContent>
                <p>{"Card Content"}</p>
            </CardContent>
            <CardFooter>
                <p>{"Card Footer"}</p>
            </CardFooter>
        </Card>
    }
}

Examples

See Also

Input

Displays a form input field or a component that looks like an input field.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add input

Usage

use yew::prelude::*;

use crate::components::ui::input::Input;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Input />
    }
}

Examples

Default

File

Disabled

With Label

With Text

With Button

Form

See Also

Label

Renders an accessible label associated with controls.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add label

Usage

use yew::prelude::*;

use crate::components::ui::label::Label;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Label r#for="email">{"Your email address"}</Label>
    }
}

See Also

Pagination

Pagination with page navigation, next and previous links.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add pagination

Usage

use yew::prelude::*;

use crate::components::ui::pagination::{
    Pagination,
    PaginationContent,
    PaginationEllipsis,
    PaginationItem,
    PaginationLink,
    PaginationNext,
    PaginationPrevious,
};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Pagination>
            <PaginationContent>
            <PaginationItem>
                <PaginationPrevious href="#" />
            </PaginationItem>
            <PaginationItem>
                <PaginationLink href="#">{"1"}</PaginationLink>
            </PaginationItem>
            <PaginationItem>
                <PaginationEllipsis />
            </PaginationItem>
            <PaginationItem>
                <PaginationNext href="#" />
            </PaginationItem>
            </PaginationContent>
        </Pagination>
    }
}

Router

By default the <PaginationLink /> component will render an <a /> tag.

To use a router link component, make the following updates to pagination.rs:

+ use yew_router::prelude::*;

  html! {
-     <a>
+     <Link>
          // ...
-     </a>
+     </Link>
  }

See Also

Separator

Visually or semantically separates content.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add separator

Usage

use yew::prelude::*;

use crate::components::ui::separator::Separator;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Separator />
    }
}

See Also

Skeleton

Use to show a placeholder while content is loading.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add skeleton

Usage

use yew::prelude::*;

use crate::components::ui::skeleton::{Skeleton};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Skeleton class="w-[100px] h-[20px] rounded-full" />
    }
}

Examples

Card

See Also

Switch

A control that allows the user to toggle between checked and not checked.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add switch

Usage

use yew::prelude::*;

use crate::components::ui::switch::Switch;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Switch />
    }
}

Examples

Form

See Also

Table

A responsive table component.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add table

Usage

use yew::prelude::*;

use crate::components::ui::table::{
    Table,
    TableBody,
    TableCaption,
    TableCell,
    TableHead,
    TableHeader,
    TableRow,
};

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Table>
            <TableCaption>{"A list of your recent invoices."}</TableCaption>
            <TableHeader>
                <TableRow>
                    <TableHead class="w-[100px]">{"Invoice"}</TableHead>
                    <TableHead>{"Status"}</TableHead>
                    <TableHead>{"Method"}</TableHead>
                    <TableHead class="text-right">{"Amount"}</TableHead>
                </TableRow>
            </TableHeader>
            <TableBody>
                <TableRow>
                    <TableCell class="font-medium">{"INV001"}</TableCell>
                    <TableCell>{"Paid"}</TableCell>
                    <TableCell>{"Credit Card"}</TableCell>
                    <TableCell class="text-right">{"$250.00"}</TableCell>
                </TableRow>
            </TableBody>
        </Table>
    }
}

See Also

Textarea

Displays a form textarea or a component that looks like a textarea.

Installation

The CLI is not yet available. For now, manually copy the component source into your project.

rust-shadcn-ui add textarea

Usage

use yew::prelude::*;

use crate::components::ui::textarea::Textarea;

#[component]
fn Usage() -> impl IntoView {
    view! {
        <Textarea />
    }
}

Examples

Default

Disabled

With Label

With Text

With Button

Form

See Also