Product

Prompt card

The site's prompt: a two-line field and a square White send button in a #1A1A1A card with the 20px corner and a #666666 ring, with an optional row naming where it works.

Install

React apps get the React files; every other stack gets the web component.

npx spyglass-ds add prompt-card
<script type="module" src="/spyglass-ds/elements/prompt-card.js"></script>
A question and where it works

Works where you work

  • Chat apps
  • Code editors
  • Any MCP client
  • REST

Usage

Asking the product a question on a hero or in a product view, where the search bar is too small for a sentence.

Never

  • Other companies' logos in the row: name the places in words
  • A typing animation that keeps running under the pointer or with reduced motion
  • A second button inside the card

Adds with it: button packages lucide-react

Props

The web component takes the same as attributes or properties (<spyglass-prompt-card>); title is heading there.

<PromptCard>

PropTypeDefault
placeholderstring

The hint in the empty field.

'Ask anything'
labelstring

The field's accessible name.

'Your question'
sendLabelstring

The send button's accessible name.

'Send'
worksLabelstring

The row's label: "Works where you work".

worksstring[]

The places it works, as words.

[]
defaultValuestring''
onSubmit(text: string) => void
namestring'q'
disabledboolean
classNamestring

Examples

The same example in React and as web components; both render identically.

react/examples/prompt-card/Ask.tsx
import { PromptCard } from '@/react/components/product/PromptCard'
// The prompt with a hint and the places it works, for Acme's search.

export default function Ask() {
  return <PromptCard placeholder="Show me the longest-running ads in running shoes." worksLabel="Works where you work" works={['Chat apps', 'Code editors', 'Any MCP client', 'REST']} />
}
elements/examples/prompt-card/Ask.html
<!-- The prompt with a hint and the places it works, for Acme's search. -->
<spyglass-prompt-card placeholder="Show me the longest-running ads in running shoes." works-label="Works where you work" works='["Chat apps","Code editors","Any MCP client","REST"]'></spyglass-prompt-card>

Source

react/components/product/PromptCard.tsx
'use client'
import { useState, type FormEvent, type Ref } from 'react'
import { ArrowUp } from 'lucide-react'
import { Button } from '@/react/components/ui/Button'
import { cn } from '@/react/lib/cn'

// The site's prompt (v3 HeroPrompt): a #1A1A1A card with the 20px corner inside a #666666 hairline ring, a two-line
// field in DM Sans 16/24 with its hint in #A3A3A3, a square White send button at the lower right, and under a hairline
// an optional row: a #A3A3A3 14/20 label and the places it works, as words in #D4D4D4 (never other companies' logos).
// While the field has focus the ring lightens to #A3A3A3 with a #666666 2px halo (160ms on the site's ease-out).
// Enter (without Shift) or the button calls onSubmit with the text.
export interface PromptCardProps {
  /** The hint in the empty field. */
  placeholder?: string
  /** The field's accessible name. */
  label?: string
  /** The send button's accessible name. */
  sendLabel?: string
  /** The row's label: "Works where you work". */
  worksLabel?: string
  /** The places it works, as words. */
  works?: string[]
  defaultValue?: string
  onSubmit?: (text: string) => void
  name?: string
  disabled?: boolean
  className?: string
  ref?: Ref<HTMLFormElement>
}

export function PromptCard({ placeholder = 'Ask anything', label = 'Your question', sendLabel = 'Send', worksLabel, works = [], defaultValue = '', onSubmit, name = 'q', disabled, className, ref }: PromptCardProps) {
  const [text, setText] = useState(defaultValue)
  const submit = (event?: FormEvent<HTMLFormElement>) => {
    event?.preventDefault()
    if (!disabled && text.trim()) onSubmit?.(text.trim())
  }
  return (
    <form data-ds="prompt-card" ref={ref} onSubmit={submit} className={cn('grid w-full max-w-200 grid-cols-1 rounded-ds-lg bg-surface-subtle px-3 pt-3 text-left shadow-[inset_0_0_0_var(--ds-border-hairline)_var(--ds-color-edge-strong)] transition-[box-shadow] duration-160 ease-out has-[textarea:focus]:shadow-[inset_0_0_0_var(--ds-border-hairline)_var(--ds-color-fg-muted),0_0_0_var(--ds-border-focus)_var(--ds-color-edge-strong)]', className)}>
      <div className="flex flex-wrap items-end justify-end gap-3 pb-3">
        <textarea
          name={name}
          value={text}
          onChange={(e) => setText(e.target.value)}
          onKeyDown={(e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); submit() } }}
          placeholder={placeholder}
          aria-label={label}
          disabled={disabled}
          rows={2}
          className="block h-18 w-full min-w-0 flex-[1_1_100%] resize-none rounded-control bg-transparent px-4 py-3 type-body text-fg outline-none placeholder:text-fg-muted disabled:cursor-not-allowed"
        />
        <Button type="submit" icon aria-label={sendLabel} disabled={disabled}><ArrowUp size={24} strokeWidth={2} aria-hidden="true" /></Button>
      </div>
      {(worksLabel || works.length > 0) && (
        <div className="grid gap-2 border-t border-edge px-4 py-3 sm:flex sm:items-center sm:justify-between">
          {worksLabel && <p className="type-ui text-fg-muted">{worksLabel}</p>}
          {works.length > 0 && <ul className="flex flex-wrap gap-x-5 gap-y-2 type-ui text-fg-soft">{works.map((w) => <li key={w}>{w}</li>)}</ul>}
        </div>
      )}
    </form>
  )
}

export default PromptCard
react/lib/cn.ts
// Joins class names, skipping falsy ones: cn('a', on && 'b', ['c', undefined]). It does not merge conflicting
// utilities (no tailwind-merge), as Vue's class binding does not: the library's classes are written not to compete,
// and a className from the caller is appended after them, as Vue appends a fallthrough class.
export type ClassValue = string | false | null | undefined | 0 | ClassValue[]

export function cn(...values: ClassValue[]): string {
	const out: string[] = []
	for (const v of values) {
		if (!v) continue
		if (Array.isArray(v)) {
			const s = cn(...v)
			if (s) out.push(s)
		}
		else out.push(v)
	}
	return out.join(' ')
}
elements/components/product/prompt-card.ts
import { html, nothing } from 'lit'
import { live } from 'lit/directives/live.js'
import { ArrowUp } from 'lucide'
import { DsElement, define, HostLayoutController } from '@/elements/lib/element'
import { icon } from '@/elements/lib/icon'
import '@/elements/components/ui/button'
import styles from 'virtual:tw'

// PromptCard.tsx as <spyglass-prompt-card>: the site's prompt card, a two-line field (`placeholder`, `label`) with a
// square White send button and an optional row (`works-label`, `works` as words). Enter (without Shift) or the button
// fires `send` with { text }.

/**
 * @summary The site's prompt: a field and a send button in a #1A1A1A card with the 20px corner.
 * @fires send - With { text } when sent.
 */
export class PromptCard extends DsElement {
	static styles = [DsElement.styles, styles]
	protected readonly layout = new HostLayoutController(this, () => this.renderRoot.querySelector<HTMLElement>('[data-ds="prompt-card"]'))
	static properties = { placeholder: {}, label: {}, sendLabel: { attribute: 'send-label' }, worksLabel: { attribute: 'works-label' }, works: { type: Array }, value: {}, name: {}, disabled: { type: Boolean, reflect: true } }
	/** The hint in the empty field. */
	placeholder = 'Ask anything'
	/** The field's accessible name. */
	label = 'Your question'
	/** The send button's accessible name. */
	sendLabel = 'Send'
	/** The row's label. */
	worksLabel?: string
	/** The places it works, as words. */
	works: string[] = []
	value = ''
	name = 'q'
	disabled = false

	private send(event?: Event) {
		event?.preventDefault()
		const text = this.value.trim()
		if (!this.disabled && text) this.emit('send', { text })
	}

	render() {
		const works = this.works ?? []
		return html`<form data-ds="prompt-card" @submit=${(e: Event) => this.send(e)} class="grid w-full max-w-200 grid-cols-1 rounded-ds-lg bg-surface-subtle px-3 pt-3 text-left shadow-[inset_0_0_0_var(--ds-border-hairline)_var(--ds-color-edge-strong)] transition-[box-shadow] duration-160 ease-out has-[textarea:focus]:shadow-[inset_0_0_0_var(--ds-border-hairline)_var(--ds-color-fg-muted),0_0_0_var(--ds-border-focus)_var(--ds-color-edge-strong)]"><div class="flex flex-wrap items-end justify-end gap-3 pb-3"><textarea name=${this.name} .value=${live(this.value)} @input=${(e: Event) => (this.value = (e.target as HTMLTextAreaElement).value)} @keydown=${(e: KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) this.send(e) }} placeholder=${this.placeholder} aria-label=${this.label} ?disabled=${this.disabled} rows="2" class="block h-18 w-full min-w-0 flex-[1_1_100%] resize-none rounded-control bg-transparent px-4 py-3 type-body text-fg outline-none placeholder:text-fg-muted disabled:cursor-not-allowed"></textarea><spyglass-button type="submit" icon aria-label=${this.sendLabel} ?disabled=${this.disabled} @click=${() => this.send()}>${icon(ArrowUp, 'arrow-up', { size: 24, strokeWidth: 2, attrs: { 'aria-hidden': 'true' } })}</spyglass-button></div>${this.worksLabel || works.length ? html`<div class="grid gap-2 border-t border-edge px-4 py-3 sm:flex sm:items-center sm:justify-between">${this.worksLabel ? html`<p class="type-ui text-fg-muted">${this.worksLabel}</p>` : nothing}${works.length ? html`<ul class="flex flex-wrap gap-x-5 gap-y-2 type-ui text-fg-soft">${works.map((w) => html`<li>${w}</li>`)}</ul>` : nothing}</div>` : nothing}</form>`
	}
}

define('prompt-card', PromptCard)

Reference: Site v3/V3Playground/HeroPrompt (HeroPrompt.module.css): card --raised with --radius-l and an inset --line-strong ring, 12px in; the field 16/24 two lines tall; the send button --control-s square; the row under a --line hairline with a 14/20 --text-3 label.