Pros & Cons Block (Astro)
contentbit/astro-pros-consFreeComponent
Paired advantages and disadvantages.
Install it
npx shadcn@latest add https://contentbit.dev/r/astro-pros-cons.jsonSource
1---2import type { ProsConsData } from '@contentbit/blocks'3import type { ValidatedBlockNode } from '@contentbit/core'4import type { AstroBlockContext } from '@contentbit/astro'56import { splitProsCons } from '@contentbit/blocks'78interface Props {9 node: ValidatedBlockNode<unknown>10 ctx: AstroBlockContext11}1213const { node, ctx } = Astro.props14const { pros, cons } = splitProsCons(node.data as ProsConsData)15const [renderedPros, renderedCons] = await Promise.all([16 Promise.all(pros.map((item) => ctx.renderMarkdown(item))),17 Promise.all(cons.map((item) => ctx.renderMarkdown(item))),18])1920// Inline lucide paths: check, x.21const CHECK = '<path d="M20 6 9 17l-5-5"/>'22const X = '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'2324const columns = [25 {26 heading: 'Pros',27 items: renderedPros,28 path: CHECK,29 head: 'bg-emerald-500/[0.07] text-emerald-700 dark:text-emerald-400',30 mark: 'text-emerald-600 dark:text-emerald-500',31 },32 {33 heading: 'Cons',34 items: renderedCons,35 path: X,36 head: 'bg-rose-500/[0.07] text-rose-700 dark:text-rose-400',37 mark: 'text-rose-600 dark:text-rose-500',38 },39]40---4142<div data-cb-styled class="my-6 grid gap-3 sm:grid-cols-2">43 {44 columns.map((col) => (45 <div class="bg-card overflow-hidden rounded-lg border">46 <div class:list={['flex items-center gap-2 border-b px-4 py-2.5', col.head]}>47 <svg48 xmlns="http://www.w3.org/2000/svg"49 viewBox="0 0 24 24"50 fill="none"51 stroke="currentColor"52 stroke-width="3"53 stroke-linecap="round"54 stroke-linejoin="round"55 class="size-3.5"56 aria-hidden="true"57 set:html={col.path}58 />59 <span class="text-xs font-semibold tracking-wider uppercase">{col.heading}</span>60 </div>61 <ul class="list-none space-y-2 p-4 text-sm">62 {col.items.map((html) => (63 <li class="flex gap-2.5">64 <svg65 xmlns="http://www.w3.org/2000/svg"66 viewBox="0 0 24 24"67 fill="none"68 stroke="currentColor"69 stroke-width="2.5"70 stroke-linecap="round"71 stroke-linejoin="round"72 class:list={['mt-1 size-3.5 shrink-0', col.mark]}73 aria-hidden="true"74 set:html={col.path}75 />76 <div class="min-w-0 leading-relaxed [&>p]:m-0" set:html={html} />77 </li>78// … truncated
What it pulls in
npm packages
Files it writes
More from contentbit
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Callout Block (Astro)astro-callout | contentbit | Components | Free | 3 deps | |
| Comparison Block (Astro)astro-comparison | contentbit | Components | Free | 3 deps | |
| Content Renderer (Astro)astro-content-renderer | contentbit | Components | Free | 3 deps | |
| FAQ Block (Astro)astro-faq | contentbit | Components | Free | 3 deps | |
| Key Metrics Block (Astro)astro-key-metrics | contentbit | Components | Free | 3 deps | |
| Quick Reference Block (Astro)astro-quick-ref | contentbit | Components | Free | 3 deps | |
| Steps Block (Astro)astro-steps | contentbit | Components | Free | 3 deps | |
| Tabs Block (Astro)astro-tabs | contentbit | Components | Free | 3 deps |
