Hero Terminal
Hero para desarrolladores con terminal animada y comando de instalación con copiar al portapapeles.
herodeveloperterminalclicopy
Vista Previa en Vivo
For developers
From zero to production in one command
Scaffold a fully accessible Astro site with sections, charts and design tokens already wired up.
$ npm create astro@latest -- --template kit~/my-site — zsh
- ❯npm create astro@latest -- --template kit
- Scaffolding project in ./my-site …
- ✓50 sections installed
- ✓45 SVG charts installed
- ❯npm run build
- 12 pages built in 1.84s
- ✓Lighthouse: 100 · 100 · 100 · 100
- ❯
Uso
Copia y pega este código directamente en tu componente React:
tsx
import { HeroTerminal } from 'react-component-kit-ui/sections';
<HeroTerminal title="From zero to production in one command" command="npm create astro@latest" lines={[
{ type: 'cmd', text: 'npm create astro@latest' },
{ type: 'ok', text: 'Project ready' },
]} />Instalación Manual
Si no estás usando el paquete npm, crea un archivo nuevo y pega el siguiente código: src/components/sections/HeroTerminal.tsx + HeroTerminal.css:
HeroTerminal.tsx
'use client';
import { useEffect, useRef } from 'react';
import type { CSSProperties } from 'react';
import './HeroTerminal.css';
/** "a: b; --c: d" → style object */
function st(css: string | undefined): CSSProperties {
const o: Record<string, string> = {};
for (const decl of String(css ?? '').split(';')) {
const i = decl.indexOf(':');
if (i < 0) continue;
const k = decl.slice(0, i).trim();
if (k) o[k.startsWith('--') ? k : k.replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = decl.slice(i + 1).trim();
}
return o as CSSProperties;
}
interface Line { type: 'cmd' | 'out' | 'ok'; text: string }
/**
* HeroTerminal — Developer-focused split hero with an animated terminal showing
* install and build commands, plus a copyable install snippet.
*
* @param {string} eyebrow - Small label above the title.
* @param {string} title - Headline.
* @param {string} subtitle - Supporting paragraph.
* @param {string} command - Install command shown in the copy field.
* @param {Array<{type: 'cmd'|'out'|'ok', text: string}>} lines - Terminal transcript.
* @param {{label: string, href: string}} primary - Primary CTA.
* @param {string} variant - Terminal style (default|glass|minimal).
* @param {string} size - Vertical rhythm (sm|md|lg).
* @param {string} className - Extra CSS class.
*/
export interface HeroTerminalProps {
eyebrow?: string;
title?: string;
subtitle?: string;
command?: string;
lines?: Line[];
primary?: { label: string; href: string };
variant?: 'default' | 'glass' | 'minimal';
size?: 'sm' | 'md' | 'lg';
className?: string;
}
export function HeroTerminal({
eyebrow = 'For developers',
title = 'From zero to production in one command',
subtitle = 'Scaffold a fully accessible Astro site with sections, charts and design tokens already wired up.',
command = 'npm create astro@latest -- --template kit',
lines = [
{ type: 'cmd', text: 'npm create astro@latest -- --template kit' },
{ type: 'out', text: 'Scaffolding project in ./my-site …' },
{ type: 'ok', text: '50 sections installed' },
{ type: 'ok', text: '45 SVG charts installed' },
{ type: 'cmd', text: 'npm run build' },
{ type: 'out', text: '12 pages built in 1.84s' },
{ type: 'ok', text: 'Lighthouse: 100 · 100 · 100 · 100' },
],
primary = { label: 'Get started', href: '#' },
variant = 'default',
size = 'md',
className = '',
}: HeroTerminalProps) {
const id = `ht-${Math.random().toString(36).slice(2, 8)}`;
// Ported from the Astro <script>: runs once after mount (DOM logic kept as in the Astro kit).
const mounted = useRef(false);
useEffect(() => {
if (mounted.current) return;
mounted.current = true;
document.querySelectorAll<HTMLButtonElement>('.ht__copy-btn').forEach((btn) => {
btn.addEventListener('click', async () => {
const status = btn.parentElement?.querySelector('.ht__status');
try {
await navigator.clipboard.writeText(btn.dataset.copy || '');
btn.classList.add('is-copied');
if (status) status.textContent = 'Copied to clipboard';
setTimeout(() => {
btn.classList.remove('is-copied');
if (status) status.textContent = '';
}, 1800);
} catch {
if (status) status.textContent = 'Copy failed — select the text manually';
}
});
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<>
<div className="cq-hero-terminal-cq" data-rk-ac30d5="">
<section className={`ht ht--${variant} ht--${size} ${className}`} aria-labelledby={id} data-rk-ac30d5="">
<div className="ht__inner" data-rk-ac30d5="">
<div className="ht__copy" data-rk-ac30d5="">
<p className="ht__eyebrow" data-rk-ac30d5="">{eyebrow}</p>
<h1 id={id} className="ht__title" data-rk-ac30d5="">{title}</h1>
<p className="ht__subtitle" data-rk-ac30d5="">{subtitle}</p>
<div className="ht__install" data-rk-ac30d5="">
<code className="ht__cmd" data-rk-ac30d5=""><span aria-hidden="true" data-rk-ac30d5="">$ </span>{command}</code>
<button type="button" className="ht__copy-btn" data-copy={command} aria-label="Copy install command" data-rk-ac30d5="">
<svg className="ht__icon-copy" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true" data-rk-ac30d5=""><rect x="9" y="9" width="13" height="13" rx="2" data-rk-ac30d5="" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" data-rk-ac30d5="" /></svg>
<svg className="ht__icon-ok" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" aria-hidden="true" data-rk-ac30d5=""><path d="M20 6 9 17l-5-5" data-rk-ac30d5="" /></svg>
</button>
<span className="ht__status" role="status" aria-live="polite" data-rk-ac30d5=""></span>
</div>
<a className="ht__btn" href={primary.href} data-rk-ac30d5="">
{primary.label}
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true" data-rk-ac30d5=""><path d="M5 12h14M13 6l6 6-6 6" data-rk-ac30d5="" /></svg>
</a>
</div>
<div className="ht__terminal" role="img" aria-label={`Terminal transcript: ${lines.map((l) => l.text).join('. ')}`} data-rk-ac30d5="">
<div className="ht__bar" aria-hidden="true" data-rk-ac30d5="">
<span data-rk-ac30d5=""></span><span data-rk-ac30d5=""></span><span data-rk-ac30d5=""></span>
<p data-rk-ac30d5="">~/my-site — zsh</p>
</div>
<ol className="ht__lines" aria-hidden="true" data-rk-ac30d5="">
{lines.map((l, i) => (
<li key={i} className={`ht__line ht__line--${l.type}`} style={st(`--i:${i}`)} data-rk-ac30d5="">
{l.type === 'cmd' && <span className="ht__prompt" data-rk-ac30d5="">❯</span>}
{l.type === 'ok' && <span className="ht__ok" data-rk-ac30d5="">✓</span>}
{l.text}
</li>
))}
<li className="ht__line ht__cursor" style={st(`--i:${lines.length}`)} data-rk-ac30d5=""><span className="ht__prompt" data-rk-ac30d5="">❯</span><span className="ht__caret" data-rk-ac30d5=""></span></li>
</ol>
</div>
</div>
</section>
</div>
</>
);
}
export default HeroTerminal;HeroTerminal.css
/* HeroTerminal — ported from astro-component-kit (sections/HeroTerminal.astro) */
.cq-hero-terminal-cq:where([data-rk-ac30d5]) { container-type: inline-size; }
.ht:where([data-rk-ac30d5]) {
--ht-py: 5.5rem;
padding: var(--ht-py) var(--sp-6, 1.5rem);
background: radial-gradient(ellipse 50% 60% at 85% 40%, rgba(57, 135, 229, 0.08), transparent 70%), var(--c-bg, #050505);
}
.ht--sm:where([data-rk-ac30d5]) { --ht-py: 3.5rem; }
.ht--lg:where([data-rk-ac30d5]) { --ht-py: 7.5rem; }
.ht__inner:where([data-rk-ac30d5]) {
max-width: 1180px;
margin: 0 auto;
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
gap: 4rem;
align-items: center;
}
.ht__eyebrow:where([data-rk-ac30d5]) {
margin: 0 0 1rem;
font-family: var(--font-mono, monospace);
font-size: 0.8125rem;
color: var(--c-primary-light, #d4a017);
letter-spacing: 0.04em;
}
.ht__title:where([data-rk-ac30d5]) {
margin: 0 0 1.25rem;
font-size: clamp(2.25rem, 4.5vw, 3.5rem);
font-weight: 800;
letter-spacing: -0.03em;
line-height: 1.08;
color: var(--c-text-1, #fff);
text-wrap: balance;
}
.ht__subtitle:where([data-rk-ac30d5]) { margin: 0 0 2rem; font-size: 1.0625rem; line-height: 1.65; color: var(--c-text-2, #a3a3a3); max-width: 520px; }
.ht__install:where([data-rk-ac30d5]) {
display: flex;
align-items: center;
gap: 0.5rem;
max-width: 520px;
padding: 0.4rem 0.4rem 0.4rem 1rem;
border-radius: var(--r-md, 12px);
border: 1px solid var(--c-border, rgb(var(--ink-rgb, 255 255 255) / 0.08));
background: rgb(var(--ink-rgb, 255 255 255) / 0.025);
margin-bottom: 1.5rem;
position: relative;
}
.ht__cmd:where([data-rk-ac30d5]) {
flex: 1;
min-width: 0;
overflow-x: auto;
white-space: nowrap;
font-family: var(--font-mono, monospace);
font-size: 0.875rem;
color: var(--c-text-1, #fff);
}
.ht__cmd:where([data-rk-ac30d5]) span:where([data-rk-ac30d5]) { color: var(--c-text-3, #737373); }
.ht__copy-btn:where([data-rk-ac30d5]) {
display: grid;
place-items: center;
width: 44px;
height: 44px;
flex-shrink: 0;
border: 0;
border-radius: var(--r-sm, 8px);
background: rgb(var(--ink-rgb, 255 255 255) / 0.05);
color: var(--c-text-2, #a3a3a3);
cursor: pointer;
transition: background 0.2s ease, color 0.2s ease;
}
.ht__copy-btn:hover:where([data-rk-ac30d5]) { background: rgb(var(--ink-rgb, 255 255 255) / 0.1); color: var(--c-text-1, #fff); }
.ht__copy-btn:focus-visible:where([data-rk-ac30d5]), .ht__btn:focus-visible:where([data-rk-ac30d5]) { outline: 2px solid var(--c-primary-light, #d4a017); outline-offset: 2px; }
.ht__icon-ok:where([data-rk-ac30d5]) { display: none; color: var(--chart-pos, #34c38f); }
.ht__copy-btn.is-copied:where([data-rk-ac30d5]) .ht__icon-copy:where([data-rk-ac30d5]) { display: none; }
.ht__copy-btn.is-copied:where([data-rk-ac30d5]) .ht__icon-ok:where([data-rk-ac30d5]) { display: block; }
.ht__status:where([data-rk-ac30d5]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ht__btn:where([data-rk-ac30d5]) {
display: inline-flex;
align-items: center;
gap: 0.5rem;
min-height: 48px;
padding: 0 1.5rem;
border-radius: var(--r-md, 12px);
background: var(--c-text-1, #fff);
color: var(--c-on-primary, #0a0a0a);
font-weight: 650;
text-decoration: none;
transition: transform 0.2s ease;
}
.ht__btn:hover:where([data-rk-ac30d5]) { transform: translateY(-1px); color: var(--c-on-primary, #0a0a0a); }
.ht__terminal:where([data-rk-ac30d5]) {
border-radius: var(--r-lg, 20px);
border: 1px solid rgb(var(--ink-rgb, 255 255 255) / 0.09);
background: #0b0b0d;
box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgb(var(--ink-rgb, 255 255 255) / 0.02) inset;
overflow: hidden;
}
.ht--glass:where([data-rk-ac30d5]) .ht__terminal:where([data-rk-ac30d5]) { background: rgba(14, 14, 18, 0.6); backdrop-filter: blur(18px); }
.ht--minimal:where([data-rk-ac30d5]) .ht__terminal:where([data-rk-ac30d5]) { box-shadow: none; }
.ht__bar:where([data-rk-ac30d5]) {
display: flex;
align-items: center;
gap: 0.45rem;
padding: 0.85rem 1rem;
border-bottom: 1px solid rgb(var(--ink-rgb, 255 255 255) / 0.06);
}
.ht__bar:where([data-rk-ac30d5]) span:where([data-rk-ac30d5]) { width: 11px; height: 11px; border-radius: 50%; background: rgb(var(--ink-rgb, 255 255 255) / 0.12); }
.ht__bar:where([data-rk-ac30d5]) p:where([data-rk-ac30d5]) { margin: 0 auto; font-size: 0.75rem; color: var(--c-text-3, #737373); font-family: var(--font-mono, monospace); transform: translateX(-1.5rem); }
.ht__lines:where([data-rk-ac30d5]) {
list-style: none;
margin: 0;
padding: 1.25rem 1.25rem 1.5rem;
font-family: var(--font-mono, monospace);
font-size: 0.8125rem;
line-height: 1.9;
min-height: 260px;
}
.ht__line:where([data-rk-ac30d5]) {
display: flex;
gap: 0.6rem;
opacity: 0;
animation: hero-terminal-ht-in 0.35s ease forwards;
animation-delay: calc(var(--i) * 0.45s + 0.3s);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.ht__line--cmd:where([data-rk-ac30d5]) { color: var(--c-text-1, #fff); }
.ht__line--out:where([data-rk-ac30d5]) { color: var(--c-text-3, #8a8a8a); padding-left: 1.2rem; }
.ht__line--ok:where([data-rk-ac30d5]) { color: var(--c-text-2, #c4c4c4); padding-left: 1.2rem; }
.ht__prompt:where([data-rk-ac30d5]) { color: var(--c-primary-light, #d4a017); }
.ht__ok:where([data-rk-ac30d5]) { color: var(--chart-pos, #34c38f); }
.ht__caret:where([data-rk-ac30d5]) { width: 8px; height: 1.1em; align-self: center; background: var(--c-text-1, #fff); animation: hero-terminal-ht-blink 1s steps(1) infinite; }
@keyframes hero-terminal-ht-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes hero-terminal-ht-blink { 50% { opacity: 0; } }
@container (max-width: 900px) {
.ht__inner:where([data-rk-ac30d5]) { grid-template-columns: minmax(0, 1fr); gap: 3rem; }
}
@media (prefers-reduced-motion: reduce) {
.ht__line:where([data-rk-ac30d5]) { animation: none; opacity: 1; }
.ht__caret:where([data-rk-ac30d5]) { animation: none; }
}