defuss-shadcn / Website / Company / service-item
Built with: CSS
Service ItemBLK
Introduces one service with its description and detail link - as a card with an icon, a card with a picture, or an inline row. Part of the Company blocks.
On this page (4)
§Cards
Default cards: an icon tile, the title (its link covers the card), a description and an arrow cue that slides on hover; the card lifts a little.
§With pictures
data-variant='image': a 16:9 picture bleeds into the top of the card instead of the icon.
§Inline
data-variant='inline': no card - the icon beside the text, a quiet highlight on hover. For dense lists and sidebars.
§CSS view file
/* -- Service Item (website · Company) ------------------------------------- Introduces one service with its description and detail link - as a card with an icon, a card with a picture, or an inline row. */@layer components { /* every box in the block measures border-box - the same on any page */ :where(.mk-service-item, .mk-service-item *, .mk-service-item ::before, .mk-service-item ::after) { box-sizing: border-box; } .mk-service-item { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--card-foreground); transition: translate 200ms ease, box-shadow 200ms ease, border-color 200ms ease; &:hover { translate: 0 -2px; box-shadow: var(--shadow-lg); border-color: color-mix(in oklch, var(--foreground) 20%, var(--border)); } } .mk-service-item { position: relative; } .mk-service-item-title a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } .mk-service-item-title a:focus-visible { outline: none; } .mk-service-item:has(.mk-service-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-service-item :is(button, input, select, label, .btn):not(.mk-service-item-title a)) { position: relative; z-index: 1; } .mk-service-item-icon { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; border-radius: var(--radius-lg); background: color-mix(in oklch, var(--primary) 10%, transparent); color: var(--primary); & svg { width: 1.375rem; height: 1.375rem; } } .mk-service-item-media { display: block; width: calc(100% + 3rem); margin: -1.5rem -1.5rem 0.25rem; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-xl) var(--radius-xl) 0 0; } .mk-service-item-title { margin: 0.25rem 0 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; & a { color: inherit; text-decoration: none; } } .mk-service-item-desc { margin: 0; flex: 1; color: var(--muted-foreground); font-size: 0.9375rem; line-height: 1.6; text-wrap: pretty; } .mk-service-item-more { display: inline-flex; align-items: center; gap: 0.25rem; margin-block-start: 0.25rem; color: var(--primary); font-size: 0.875rem; font-weight: 600; & svg { width: 0.875rem; height: 0.875rem; transition: translate 150ms ease; } } .mk-service-item:hover .mk-service-item-more svg { translate: 0.25rem 0; } .mk-service-item[data-variant="inline"] { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 1rem; row-gap: 0.25rem; padding: 0.75rem; border-color: transparent; background: transparent; &:hover { translate: none; box-shadow: none; background: var(--accent); border-color: transparent; } & .mk-service-item-icon { grid-row: 1 / span 3; } & .mk-service-item-title { margin: 0; font-size: 1rem; } & .mk-service-item-more { display: none; } } /* -- Accessibility ------------------------------------------- */ @media (prefers-reduced-motion: reduce) { .mk-service-item, .mk-service-item-more svg { transition: none; } .mk-service-item:hover { translate: none; } .mk-service-item:hover .mk-service-item-more svg { translate: none; } } @media (forced-colors: active) { .mk-service-item { border-color: CanvasText; } }}Comments, ideas or improvements? Edit this page's source on GitHub