shadcn.io is not affiliated with official shadcn/ui
Shadcn Announcement for React and Tailwind
Inline notice for short, prominent updates.
Releasev2.1.0 — Dark mode, faster builds, and 12 new components
Installation
bunx --bun shadcn@latest add https://kit.dev/r/announcement.jsonpnpm dlx shadcn@latest add https://kit.dev/r/announcement.jsonnpx shadcn@latest add https://kit.dev/r/announcement.jsonyarn shadcn@latest add https://kit.dev/r/announcement.jsonThis component depends on Badge. Install it first if you haven't already.
Install the following dependencies:
bun add @ark-ui/react tailwind-variantspnpm add @ark-ui/react tailwind-variantsnpm install @ark-ui/react tailwind-variantsyarn add @ark-ui/react tailwind-variantsAdd the following to your globals.css.
:root {
--destructive-foreground: var(--color-red-700);
--info: var(--color-blue-500);
--info-foreground: var(--color-blue-700);
--success: var(--color-emerald-500);
--success-foreground: var(--color-emerald-700);
--warning: var(--color-amber-500);
--warning-foreground: var(--color-amber-700);
}
.dark {
--destructive-foreground: var(--color-red-400);
--info: var(--color-blue-500);
--info-foreground: var(--color-blue-400);
--success: var(--color-emerald-500);
--success-foreground: var(--color-emerald-400);
--warning: var(--color-amber-500);
--warning-foreground: var(--color-amber-400);
}Copy and paste the following code into your project.
"use client";
import { ark } from "@ark-ui/react/factory";
import type React from "react";
import { tv, type VariantProps } from "tailwind-variants";
import { cn } from "@/lib/utils";
export const announcementVariants = tv({
base: [
"group/announcement",
"relative",
"inline-flex min-w-0 max-w-full items-center gap-2",
"py-0.5 ps-3 pe-3",
"bg-input/4",
"rounded-2xl border border-input",
"transition-colors",
"outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-ring/32",
"[&_svg]:size-3.5 [&_svg]:shrink-0",
"has-data-[slot=badge]:ps-0.5",
"[button&,a&]:cursor-pointer",
"[&>svg]:text-muted-foreground",
"[a&]:hover:bg-input/12",
"**:data-[slot=badge]:h-6.5 **:data-[slot=badge]:rounded-xl **:data-[slot=badge]:px-2 **:data-[slot=badge]:sm:text-xs",
"[button&,a&]:pointer-coarse:after:absolute [button&,a&]:pointer-coarse:after:size-full [button&,a&]:pointer-coarse:after:min-h-11 [button&,a&]:pointer-coarse:after:min-w-11",
"motion-reduce:transition-none!",
],
});
interface AnnouncementProps
extends React.ComponentProps<typeof ark.div>,
VariantProps<typeof announcementVariants> {
/**
* The ARIA role of the announcement.
*
* @default "status"
*/
role?: "status" | "alert";
}
export const Announcement = (props: AnnouncementProps) => {
const { className, role = "status", ...rest } = props;
return (
<ark.div
className={cn(announcementVariants(), className)}
data-slot="announcement"
role={role}
{...rest}
/>
);
};
export const AnnouncementTitle = (
props: React.ComponentProps<typeof ark.span>
) => {
const { className, ...rest } = props;
return (
<ark.span
className={cn(
"min-w-0",
"inline-flex flex-1 items-center gap-1",
"select-none truncate font-medium text-sm",
className
)}
data-slot="announcement-title"
{...rest}
/>
);
};Update the import paths to match your project setup.
Usage
import { Badge } from "@registry/react/components/badge";
import {
Announcement,
AnnouncementTitle,
} from "@/components/ui/announcement";<Announcement>
<Badge>Release</Badge>
<AnnouncementTitle>
v2.1.0 — Dark mode, faster builds, and 12 new components
</AnnouncementTitle>
</Announcement>Demos
Variant Default
Variant Destructive
Variant Info
Variant Success
Variant Warning
With Icon
With Link
Without Badge
API Reference
Announcement
div
PropType
AttributeType
AnnouncementTitle
span
PropType
AttributeType