<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sheryar Ahmed</title>
    <description>The latest articles on DEV Community by Sheryar Ahmed (@sheryar_ahmed).</description>
    <link>https://dev.to/sheryar_ahmed</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2307239%2F55509ae9-f4f7-491a-93f4-95188b650c33.jpg</url>
      <title>DEV Community: Sheryar Ahmed</title>
      <link>https://dev.to/sheryar_ahmed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sheryar_ahmed"/>
    <language>en</language>
    <item>
      <title>"an AI-interview experience with zero AI and zero cost." Opens with the three bills you didn't pay (TTS, Whisper, proctoring vendor)</title>
      <dc:creator>Sheryar Ahmed</dc:creator>
      <pubDate>Tue, 07 Jul 2026 20:57:07 +0000</pubDate>
      <link>https://dev.to/sheryar_ahmed/an-ai-interview-experience-with-zero-ai-and-zero-cost-opens-with-the-three-bills-you-didnt-pay-1jmm</link>
      <guid>https://dev.to/sheryar_ahmed/an-ai-interview-experience-with-zero-ai-and-zero-cost-opens-with-the-three-bills-you-didnt-pay-1jmm</guid>
      <description>&lt;h1&gt;
  
  
  A mock interviewer that speaks, listens, and proctors with no AI bill
&lt;/h1&gt;

&lt;p&gt;Demo: &lt;a href="https://drive.google.com/file/d/13WEiJXqwq7O6XzouhUR0LpNfgz67znd9/view?usp=sharing" rel="noopener noreferrer"&gt;https://drive.google.com/file/d/13WEiJXqwq7O6XzouhUR0LpNfgz67znd9/view?usp=sharing&lt;/a&gt;&lt;br&gt;
Mentors on my platform wanted to run practice interviews with their mentees: a voice&lt;br&gt;
asks a question, the candidate answers out loud, it gets recorded, and — because it's&lt;br&gt;
practice for the real thing the session is proctored. Every off-the-shelf version of&lt;br&gt;
this hands you three metered bills: a &lt;strong&gt;TTS&lt;/strong&gt; service to read the question, an &lt;strong&gt;STT&lt;/strong&gt;&lt;br&gt;
service (usually Whisper) to transcribe the answer, and a proctoring vendor to watch the&lt;br&gt;
room. Three subscriptions for a feature people use in short bursts.&lt;/p&gt;

&lt;p&gt;The naive plan is to just pay them. Wire up a cloud TTS voice, POST each audio answer to&lt;br&gt;
a speech-to-text endpoint, embed a proctoring SDK, and eat the per-minute cost forever.&lt;br&gt;
It works, but every one of those is a recurring charge, a data-egress path, and a privacy&lt;br&gt;
footprint — for something that's fundamentally &lt;em&gt;the candidate's own browser talking to&lt;br&gt;
the candidate's own microphone&lt;/em&gt;. I didn't want a network round-trip sitting between a&lt;br&gt;
mentee and a practice question.&lt;/p&gt;
&lt;h2&gt;
  
  
  The decision
&lt;/h2&gt;

&lt;p&gt;I asked how much of the stack the browser already ships, and the answer was: nearly all&lt;br&gt;
of it. The whole "AI interviewer" experience is three native Web APIs in a trench coat.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TTS — the interviewer speaks.&lt;/strong&gt; &lt;code&gt;window.speechSynthesis&lt;/code&gt; renders the question on-device.&lt;br&gt;
The mentor even tunes the pitch/rate so the interviewer ("Aria") has a personality. No&lt;br&gt;
audio is generated on a server; nothing is downloaded.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;STT — the answer transcribes itself.&lt;/strong&gt; &lt;code&gt;SpeechRecognition&lt;/code&gt; (&lt;code&gt;webkitSpeechRecognition&lt;/code&gt;&lt;br&gt;
in Chromium) does live, &lt;strong&gt;streaming&lt;/strong&gt; transcription on-device — &lt;code&gt;interimResults&lt;/code&gt; means&lt;br&gt;
words land on screen as they're spoken, the same engine behind your phone keyboard's mic&lt;br&gt;
button. No upload, no Whisper invoice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Audio streaming — the recording is the ground truth.&lt;/strong&gt; &lt;code&gt;MediaRecorder&lt;/code&gt; captures the mic&lt;br&gt;
to a chunked &lt;code&gt;audio/webm&lt;/code&gt; blob. That blob is the &lt;em&gt;only&lt;/em&gt; byte that touches my server, and&lt;br&gt;
it goes to storage I already pay for.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// TTS: the interviewer reads the prompt (mentor-tuned voice)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SpeechSynthesisUtterance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;interviewer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pitch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;interviewer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pitch&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;speechSynthesis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cancel&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;            &lt;span class="c1"&gt;// never overlap two questions&lt;/span&gt;
&lt;span class="nx"&gt;speechSynthesis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;speak&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;u&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// STT: live, streaming transcript — no server in the loop&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;rec&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;SpeechRecognition&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;webkitSpeechRecognition&lt;/span&gt;&lt;span class="p"&gt;)();&lt;/span&gt;
&lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;continuous&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;interimResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;rec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onresult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTranscript&lt;/span&gt;&lt;span class="p"&gt;([...&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="c1"&gt;// Audio streaming: MediaRecorder is the ground truth if STT is unsupported&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MediaRecorder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;mimeType&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;audio/webm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="nx"&gt;mr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ondataavailable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;size&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;chunks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The key judgment call is &lt;em&gt;layering&lt;/em&gt;, not just "use the free thing." STT support is uneven&lt;br&gt;
(Firefox notably lags), so transcription is never the source of truth — the &lt;strong&gt;recording&lt;/strong&gt;&lt;br&gt;
is. STT degrades to a nicety; the feature never breaks. And a green-room mic check runs a&lt;br&gt;
lightweight &lt;strong&gt;VAD&lt;/strong&gt;-style level meter off the Web Audio &lt;code&gt;AnalyserNode&lt;/code&gt; (RMS on the time-&lt;br&gt;
domain data) so a candidate can &lt;em&gt;see&lt;/em&gt; the mic is live before the clock starts — again,&lt;br&gt;
zero network, pure &lt;code&gt;getByteTimeDomainData&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Tally: TTS $0, STT $0, proctoring $0. The only recurring cost is the audio blob storage I&lt;br&gt;
already had.&lt;/p&gt;
&lt;h2&gt;
  
  
  The gotcha
&lt;/h2&gt;

&lt;p&gt;Proctoring is where "free browser signals" nearly bit me. The harness itself is cheap and&lt;br&gt;
honest — fullscreen lock, tab/blur focus-loss counting, copy/paste/right-click blocking,&lt;br&gt;
periodic webcam snapshots, all buffered client-side and flushed in batches. The trap was a&lt;br&gt;
kit option I was quietly proud of: &lt;strong&gt;"require camera."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I shipped it, then during testing found the guarantee was hollow. A candidate could allow&lt;br&gt;
the camera at the start, then &lt;strong&gt;turn it off mid-interview&lt;/strong&gt; from the browser's site&lt;br&gt;
controls. The session sailed on — and worse, my snapshot loop kept firing, dutifully&lt;br&gt;
uploading &lt;strong&gt;black frames&lt;/strong&gt;. On the surface everything looked compliant. "Require camera"&lt;br&gt;
that you can switch off after ten seconds isn't a requirement; it's decoration.&lt;/p&gt;

&lt;p&gt;The fix is one signal: a &lt;code&gt;MediaStreamTrack&lt;/code&gt;'s health. When a camera is turned off, covered,&lt;br&gt;
or unplugged, its track goes &lt;code&gt;muted&lt;/code&gt;/&lt;code&gt;ended&lt;/code&gt; and &lt;code&gt;readyState&lt;/code&gt; stops being &lt;code&gt;'live'&lt;/code&gt;. Poll&lt;br&gt;
that, and two behaviors fall out of the same check.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;track&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;video&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;srcObject&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;MediaStream&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;getVideoTracks&lt;/span&gt;&lt;span class="p"&gt;?.()[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;live&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;track&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;live&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;enabled&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;muted&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// (1) block instead of silently continuing&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;live&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;setCameraLive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;camera_off&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;   &lt;span class="c1"&gt;// → full-screen "turn it back on" overlay&lt;/span&gt;

&lt;span class="c1"&gt;// (2) never upload a black frame from a dead camera&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;track&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;live&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;track&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;muted&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// skip the snapshot&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when the camera drops, the runner throws a full-screen block — &lt;em&gt;"your camera is off,&lt;br&gt;
turn it back on to continue"&lt;/em&gt; with a one-click &lt;strong&gt;Retry camera&lt;/strong&gt; — and the candidate can't&lt;br&gt;
answer or advance until it's back. The clock keeps running and the off→on gap is logged,&lt;br&gt;
so turning the camera off to buy thinking time is a &lt;em&gt;recorded&lt;/em&gt; act, not a free one. And the&lt;br&gt;
mentor's proctor gallery gets a clean &lt;strong&gt;"Camera turned off"&lt;/strong&gt; flag instead of a wall of&lt;br&gt;
black rectangles. Same track state, both jobs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd do next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;STT confidence + a manual-correction pass.&lt;/strong&gt; On-device recognition trails Whisper on
accents and noise. I'd surface a confidence score and let the candidate fix the
transcript, keeping the audio as the authority.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real VAD, not just a level meter.&lt;/strong&gt; The RMS reading is enough for a "mic is live" cue;
proper voice-activity detection could auto-trim dead air and auto-advance on silence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honest limits on proctoring.&lt;/strong&gt; Client-side signals raise the &lt;em&gt;cost&lt;/em&gt; of cheating; they
don't make it impossible (a second device still exists). The goal is deterrence and an
auditable timeline for a mentor — not a courtroom — and the UI should say so.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The meta-lesson: before you add an AI line-item, check what &lt;code&gt;window&lt;/code&gt; already does for free.&lt;br&gt;
The browser quietly grew a whole speech-and-media stack — TTS, streaming STT, &lt;code&gt;MediaRecorder&lt;/code&gt;,&lt;br&gt;
Web Audio VAD, &lt;code&gt;MediaStreamTrack&lt;/code&gt; health — and most of us keep reaching for an API instead.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What's the last feature you paid a vendor for that the platform could already do TTS,&lt;br&gt;
STT, or something else?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>react</category>
    </item>
    <item>
      <title>I added dark mode by editing CSS variables not 100 components</title>
      <dc:creator>Sheryar Ahmed</dc:creator>
      <pubDate>Tue, 30 Jun 2026 13:21:06 +0000</pubDate>
      <link>https://dev.to/sheryar_ahmed/i-added-dark-mode-by-editing-css-variables-not-100-components-3n8o</link>
      <guid>https://dev.to/sheryar_ahmed/i-added-dark-mode-by-editing-css-variables-not-100-components-3n8o</guid>
      <description>&lt;h1&gt;
  
  
  I added dark mode by editing CSS variables - not 100 components
&lt;/h1&gt;

&lt;p&gt;My app had ~1,200 hardcoded &lt;code&gt;indigo-*&lt;/code&gt; and ~2,600 hardcoded &lt;code&gt;slate-*&lt;/code&gt; class usages across&lt;br&gt;
130-odd components. The brief was small to say and brutal to do: &lt;em&gt;"ship dark mode, and&lt;br&gt;
let me rebrand the accent color whenever I want."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The naive plan is a sweep: open every component, add &lt;code&gt;dark:&lt;/code&gt; variants, swap colors. That's&lt;br&gt;
weeks of work, and worse, it's &lt;em&gt;permanent&lt;/em&gt; work - every new component re-incurs it, and&lt;br&gt;
the design drifts the moment two people touch it. I wanted dark mode to be a property of&lt;br&gt;
the &lt;strong&gt;theme&lt;/strong&gt;, not of every component.&lt;/p&gt;
&lt;h2&gt;
  
  
  The decision
&lt;/h2&gt;

&lt;p&gt;Two ideas, both "edit the tokens, not the markup":&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. One brand token.&lt;/strong&gt; Instead of components knowing the color &lt;code&gt;indigo&lt;/code&gt;, they reference a&lt;br&gt;
semantic &lt;code&gt;brand&lt;/code&gt; scale. I did a one-time codemod - &lt;code&gt;indigo- → brand-&lt;/code&gt; across &lt;code&gt;app/&lt;/code&gt;,&lt;br&gt;
&lt;code&gt;components/&lt;/code&gt;, &lt;code&gt;lib/&lt;/code&gt; (~1,230 mechanical edits, no logic change) - and defined the brand&lt;br&gt;
scale once as CSS variables. Now recoloring the entire app, globally or per-user, is a&lt;br&gt;
variable swap. No component ever needs editing again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--brand-50&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#EEF4FF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* … */&lt;/span&gt; &lt;span class="py"&gt;--brand-500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#0066FF&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="py"&gt;--brand-600&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#0052D6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* … */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* Tailwind v4: expose them so bg-/text-/border-/ring-brand-* all resolve to the vars */&lt;/span&gt;
&lt;span class="k"&gt;@theme&lt;/span&gt; &lt;span class="nb"&gt;inline&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--color-brand-500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--brand-500&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--color-brand-600&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--brand-600&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c"&gt;/* …the full scale… */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Per-user accent "vibes" then become trivial - each preset just re-defines that scale under&lt;br&gt;
an attribute selector, so picking one recolors the app instantly with zero component churn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;data-accent&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"emerald"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="py"&gt;--brand-500&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#059669&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="py"&gt;--brand-600&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#047857&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* … */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Dark mode as a token remap, not a component sweep.&lt;/strong&gt; This is the part that surprised&lt;br&gt;
me.&lt;/p&gt;
&lt;h2&gt;
  
  
  The mechanism (and the wrong turn I took first)
&lt;/h2&gt;

&lt;p&gt;My first attempt failed silently. I tried mapping Tailwind's slate scale through my own&lt;br&gt;
indirection in &lt;code&gt;@theme inline&lt;/code&gt; - and text stayed dark in dark mode. Tailwind's &lt;em&gt;default&lt;/em&gt;&lt;br&gt;
&lt;code&gt;slate-*&lt;/code&gt; utilities weren't picking up my override.&lt;/p&gt;

&lt;p&gt;Then I read the compiled CSS, and the trick fell out of it. Tailwind v4 emits its own&lt;br&gt;
palette as real CSS variables, and the utilities reference them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.text-slate-900&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--color-slate-900&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So I don't need to touch a single utility. I just &lt;strong&gt;redefine the slate ramp inside the&lt;br&gt;
&lt;code&gt;.dark&lt;/code&gt; selector&lt;/strong&gt; - reversed, so "dark text" becomes light and "light background" becomes&lt;br&gt;
dark:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.dark&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--color-slate-900&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f1f5f9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c"&gt;/* was near-black → now near-white text */&lt;/span&gt;
  &lt;span class="py"&gt;--color-slate-700&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#cbd5e1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--color-slate-200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#3a4659&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c"&gt;/* was light border → now a dark border */&lt;/span&gt;
  &lt;span class="py"&gt;--color-slate-50&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="m"&gt;#273345&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c"&gt;/* was page-white → now an elevated surface */&lt;/span&gt;
  &lt;span class="py"&gt;color-scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dark&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;          &lt;span class="c"&gt;/* native scrollbars/date pickers follow too */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every &lt;code&gt;text-slate-900&lt;/code&gt;, &lt;code&gt;bg-slate-50&lt;/code&gt;, &lt;code&gt;border-slate-200&lt;/code&gt; in the codebase flips&lt;br&gt;
automatically. Thousands of usages, one block of CSS.&lt;/p&gt;
&lt;h2&gt;
  
  
  The gotcha
&lt;/h2&gt;

&lt;p&gt;A reversed ramp isn't a straight inversion - &lt;strong&gt;surface hierarchy&lt;/strong&gt; breaks if you're naive.&lt;br&gt;
My first ramp made &lt;code&gt;slate-50&lt;/code&gt; darker than my card color, so every "subtle gray" inner box&lt;br&gt;
(inside drawers and cards) suddenly looked like the page bleeding &lt;em&gt;through&lt;/em&gt; the card. The&lt;br&gt;
fix was to treat the low slate shades as &lt;strong&gt;elevated&lt;/strong&gt; surfaces that sit &lt;em&gt;above&lt;/em&gt; the card,&lt;br&gt;
not below it: &lt;code&gt;canvas (#0b1120) &amp;lt; card (#1e293b) &amp;lt; slate-50/100/200&lt;/code&gt;. Dark mode isn't&lt;br&gt;
"flip the colors" - it's "preserve the depth ordering with a dark palette." Miss that and&lt;br&gt;
everything looks flat and muddy.&lt;/p&gt;

&lt;p&gt;A second, smaller one: native &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; option lists. Components set a dark background on&lt;br&gt;
the control, but the option popup inherited the dark bg &lt;em&gt;without&lt;/em&gt; a light text color -&lt;br&gt;
dark-on-dark, invisible. One global rule fixed all of them at once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;select&lt;/span&gt; &lt;span class="nt"&gt;option&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--card&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--card-foreground&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What I'd do next
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A no-flash inline script in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; to set the theme before first paint (right now a
provider gates render, which avoids the flash but costs a frame).&lt;/li&gt;
&lt;li&gt;Audit the handful of &lt;em&gt;intentionally&lt;/em&gt; dark elements (a dark CTA, a tooltip) that I had to
pin to fixed colors so the remap couldn't invert them - those are the exceptions that
prove the rule.&lt;/li&gt;
&lt;li&gt;A contrast-ratio check in CI so a future accent preset can't ship an unreadable pair.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The meta-lesson: if changing a visual property means editing many files, the property is&lt;br&gt;
in the wrong layer. Push color and theme into tokens, and "rebrand the app" or "add dark&lt;br&gt;
mode" turns from a sprint into a diff.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What's your dark-mode strategy - &lt;code&gt;dark:&lt;/code&gt; everywhere, CSS variables, or something else?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>tailwindcss</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
