Skip to content
85 linesCodeBlameRaw
1---
2// Starlight's <LinkCard>, with Lucide's arrow, and optionally a Lucide icon
3// (its name on lucide.dev) in a lavender tile above the title.
4import type { HTMLAttributes } from 'astro/types';
5
6import LucideIcon from './LucideIcon.astro';
7
8interface Props extends Omit<HTMLAttributes<'a'>, 'title'> {
9 title: string;
10 description?: string;
11 icon?: string;
12}
13
14const { title, description, icon, ...attributes } = Astro.props;
15---
16
17<div class="sl-link-card">
18 <span class="sl-flex stack">
19 {icon && <span class="tile"><LucideIcon name={icon} size="1.125rem" /></span>}
20 <a {...attributes}>
21 <span class="title" set:html={title} />
22 </a>
23 {description && <span class="description" set:html={description} />}
24 </span>
25 <LucideIcon name="arrow-right" size="1.333em" class="icon rtl:flip" />
26</div>
27
28<style>
29 @layer starlight.components {
30 .sl-link-card {
31 display: grid;
32 grid-template-columns: 1fr auto;
33 gap: 0.5rem;
34 border: 1px solid var(--sl-color-gray-5);
35 border-radius: 0.5rem;
36 padding: 1rem;
37 box-shadow: var(--sl-shadow-sm);
38 position: relative;
39 }
40 a {
41 text-decoration: none;
42 line-height: var(--sl-line-height-headings);
43 }
44 /* The whole card is the link. */
45 a::before {
46 content: '';
47 position: absolute;
48 inset: 0;
49 }
50 .stack {
51 flex-direction: column;
52 gap: 0.5rem;
53 }
54 .tile {
55 display: inline-flex;
56 align-items: center;
57 justify-content: center;
58 width: 2.25rem;
59 height: 2.25rem;
60 margin-bottom: 0.25rem;
61 border-radius: 0.6rem;
62 background: var(--g1t-accent-low);
63 color: var(--g1t-accent);
64 }
65 .title {
66 color: var(--sl-color-white);
67 font-weight: 600;
68 font-size: var(--sl-text-lg);
69 }
70 .description {
71 color: var(--sl-color-gray-3);
72 line-height: 1.5;
73 }
74 .sl-link-card :global(.icon) {
75 color: var(--sl-color-gray-3);
76 }
77 .sl-link-card:hover {
78 background: var(--sl-color-gray-7, var(--sl-color-gray-6));
79 border-color: var(--sl-color-gray-2);
80 }
81 .sl-link-card:hover :global(.icon) {
82 color: var(--sl-color-white);
83 }
84 }
85</style>