Build a Brand Color Palette Generator with WCAG Contrast Checker in One HTML File

Generates a single-file palette tool that derives tints, shades and accent colors from one base color, tests text and background pairs against WCAG contrast ratios, and exports CSS variables.

You getFull HTML file in one code block, A recommended usage table and risks and missing information

The prompt

Prompt
Role: You are a front-end developer with strong accessibility and color-theory knowledge, building a practical design utility.

Context: The brand is Harbor Coffee Roasters (example value for {brand_name}), the base color is #1f6f78 (example value for {base_color}), and the palette will be used for a small-business website and printed menus (example value for {use_case}). The decision this tool supports is which color pairs are safe to use for text, buttons and backgrounds, and which must be avoided.

Task: Produce one self-contained HTML file (inline CSS and JS, no libraries, no network calls) that generates a palette and audits its contrast.

Inputs (list assumptions first if any are missing):
- Base color in hex, RGB or HSL, with a color picker and text field kept in sync
- Palette mode: tints and shades scale, complementary, analogous, triadic
- Light or dark page background to preview against

Workflow:
1. Write an Assumptions list (contrast formula follows WCAG 2.x relative luminance; thresholds are 4.5:1 normal text, 3:1 large text and UI components, 7:1 enhanced).
2. Convert colors between hex, RGB and HSL in plain JavaScript, with input validation and a clear error for invalid values.
3. Generate a 10-step scale (50 to 900) from the base color by adjusting HSL lightness, plus the chosen harmony colors.
4. Render swatches with name, hex, and click-to-copy.
5. Build a contrast matrix table for the scale's text-on-background combinations with ratio values and Pass AA, Pass AAA, Large only, or Fail labels in text, not color alone.
6. Add a live preview card with a heading, body text, a primary button and a link, using pickable foreground and background from the palette, with the ratio shown.
7. Export buttons: copy CSS custom properties, copy JSON, and download as .css.

Constraints: Offline only. Accessible markup with labels and focus states. No claim that passing the ratio alone makes a design accessible. Keep the code readable with short comments.

Output format:
1. Assumptions
2. Full HTML file in one code block
3. A recommended usage table: role (text, background, button, border) with suggested palette steps for Harbor Coffee Roasters (example value for {brand_name}), based on the tool's logic
4. Risks and missing information (color blindness, print, gradients, brand guidelines) with next actions
5. Three next-step upgrade ideas

Acceptance criteria:
- Black on white shows 21:1 and the label Pass AAA
- An invalid hex shows a message and does not break the page
- Exported CSS variables paste directly into a stylesheet and are named consistently
- Every pass/fail label is readable without relying on color

Quality checks: Verify the luminance function against the black and white case and one mid-gray pair. Confirm the scale is monotonic from light to dark, that copy-to-clipboard has a fallback, and that the preview updates when the base color changes. List anything you could not test.

Dashed parts are example values, so the prompt runs as copied. Change them in Fill in the blanks.

Start with your real brand hex value and pick the mode that fits your design. Use the contrast matrix to choose text and button pairs, then check results with real users and tools for color-vision differences.

Make it repeatable

Keep using this prompt without pasting it in every time.

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

Keep exploring

More in Mini Apps & Tools