Motion
p-slash-hover
A class for secondary and ghost buttons and links: on hover and keyboard focus a fill wipes in behind an edge at the slash angle, in the reading direction, and the text turns to the page colour. Not for primary buttons: their fill is already there. No hover state on touch. With reduced motion, and in browsers without lh or atan() (Chrome < 111, Safari < 16.4, Firefox < 120), the fill fades in.
@import "@percentsa/motion/styles.css";
Examples
Read the privacy policy.
Code
export function SlashHoverExample() {
const t = useT();
return (
<Stack gap={6} align="start">
<Inline gap={3}>
<Button variant="secondary" className="p-slash-hover">
{t("Start a project", "ابدأ مشروعًا")}
</Button>
<Button variant="ghost" className="p-slash-hover">
{t("See our work", "شاهد أعمالنا")}
</Button>
<Button variant="secondary" iconOnly aria-label={t("Next", "التالي")} className="p-slash-hover">
<ArrowRight aria-hidden className="rtl:-scale-x-100" />
</Button>
</Inline>
<Text tone="muted">
{t("Read the ", "اقرأ ")}
<Link href="#privacy" className="p-slash-hover px-1">
{t("privacy policy", "سياسة الخصوصية")}
</Link>
.
</Text>
</Stack>
);
}
// These docs opt in with "slash": the link below plays it.