defuss-shadcn / Website / Docs & Help / resource-item
Built with: CSS
Resource ItemBLK
Previews one guide, document, template, or other resource - its type, title, a line on what is inside, the format and the action. Part of the Docs & Help blocks.
On this page (4)
§Library
Default cards: the type with an icon, the title link covering the card, a description, the format or length and an action cue that matches the type.
§Compact
data-variant='compact': one row each - type, title and meta - for long lists.
§Featured
data-variant='featured': a picture beside the text - one highlighted resource.
§CSS view file
/* -- Resource Item (website · Docs & Help) -------------------------------- Previews one guide, document, template, or other resource - its type, title, a line on what is inside, the format and the action. */@layer components { /* every box in the block measures border-box - the same on any page */ :where(.mk-resource-item, .mk-resource-item *, .mk-resource-item ::before, .mk-resource-item ::after) { box-sizing: border-box; } .mk-resource-item { display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--card-foreground); transition: border-color 150ms ease, box-shadow 150ms ease; &:hover { border-color: color-mix(in oklch, var(--foreground) 25%, var(--border)); box-shadow: var(--shadow-md); } } .mk-resource-item { position: relative; } .mk-resource-item-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } .mk-resource-item-title a:focus-visible { outline: none; } .mk-resource-item:has(.mk-resource-item-title a:focus-visible) { outline: 2px solid var(--ring); outline-offset: 2px; } /* zero specificity: any block rule may still position its controls */ :where(.mk-resource-item :is(button, input, select, label, .btn):not(.mk-resource-item-title a)) { position: relative; z-index: 1; } .mk-resource-item-body { display: grid; gap: 0.375rem; flex: 1; align-content: start; } .mk-resource-item-type { display: inline-flex; align-items: center; gap: 0.375rem; width: fit-content; margin-block-end: 0.25rem; padding: 0.125rem 0.5rem; border-radius: 999px; background: var(--muted); font-size: 0.75rem; font-weight: 600; & svg { width: 0.875rem; height: 0.875rem; } } .mk-resource-item-title { margin: 0; font-size: 1.0625rem; font-weight: 600; line-height: 1.35; text-wrap: balance; & a { color: inherit; text-decoration: none; } } .mk-resource-item-desc { margin: 0; color: var(--muted-foreground); font-size: 0.9375rem; line-height: 1.55; } .mk-resource-item-meta { margin: 0.25rem 0 0; color: var(--muted-foreground); font-size: 0.8125rem; } .mk-resource-item-cta { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--primary); font-size: 0.875rem; font-weight: 600; & svg { width: 0.875rem; height: 0.875rem; transition: translate 150ms ease; } } .mk-resource-item:hover .mk-resource-item-cta svg { translate: 0.25rem 0; } .mk-resource-item-media { display: block; width: 100%; object-fit: cover; border-radius: var(--radius-lg); } .mk-resource-item[data-variant="compact"] { flex-direction: row; align-items: center; padding: 1rem 1.25rem; & .mk-resource-item-body { grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 0.75rem; } & .mk-resource-item-type { grid-row: span 2; margin: 0; } & .mk-resource-item-desc { display: none; } & .mk-resource-item-meta { margin: 0; } } .mk-resource-item[data-variant="featured"] { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); align-items: center; gap: 1.5rem 2rem; & .mk-resource-item-media { aspect-ratio: 16 / 10; grid-row: span 2; } & .mk-resource-item-title { font-size: 1.5rem; letter-spacing: -0.02em; } } /* -- Accessibility ------------------------------------------- */ @media (prefers-reduced-motion: reduce) { .mk-resource-item, .mk-resource-item-cta svg { transition: none; } .mk-resource-item:hover .mk-resource-item-cta svg { translate: none; } } @media (forced-colors: active) { .mk-resource-item { border-color: CanvasText; } }}Comments, ideas or improvements? Edit this page's source on GitHub