Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Translation View Reviews Block for React

Four sleeping bag reviews written in German, Spanish, French and Dutch as two-column cells with the original beside a typed translation, a Select that picks English, Spanish or French, a Show original switch and a Translation first toggle.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A translated-reviews section for React with Base UI, for the Holmbridge Fell 0, a fictional sleeping bag. Four reviews from four countries, written in German, Spanish, French and Dutch, sit in cells that share hairlines. Each cell has the reviewer with a language badge, the country, a "Verified purchase" mark in words, the stars with their value in words and a fixed date; then two columns, the original and the translation, with a line saying "Translated from German into English". A Select at the end of the header picks the language to translate into (English, Spanish or French); a review already in that language shows only itself and says so. A Switch hides the originals, and a Toggle on each cell puts the translation first. Every translation is typed for this demo, and nothing is translated live. It uses Select, Switch, Toggle, Badge, Rating, Avatar and Guides. On a phone the translation sits under the original.

FAQ

Are the translations live?

No: they're typed in REVIEWS, each under its target language code, and every cell says "Typed for this demo". There is no translation service, and the page sends nothing anywhere. To translate for real, call your service when the Select changes (or when the page loads) and fill the same shape: a text per review per language. The original text keeps its own lang attribute, so a screen reader pronounces it in its language.

What happens when the language I pick is the review's own?

The cell shows only the original and its line says "Written in Spanish: nothing to translate", with no second column and no Translation first toggle. The status line counts how many reviews were translated and how many were already in the language. Add a language by adding an item to TARGETS and a text for it to each review.

What do Show original and Translation first do?

Show original off leaves only the translation in each cell; on, you get both columns. Translation first, on each cell, swaps the order of its two columns, so on a phone the translation sits above the original. Both are real controls with a state; the order in the page is the order you read.

Why doesn't the page move when I change the language?

An unseen copy of every cell, in each language with both columns, shares the list's grid cell, so the cell is always as tall as the tallest case; the live list sits at its start. The copy is aria-hidden and inert. Hiding the originals leaves a calm gap under the cells instead of pulling the next section up.

Does it work right to left?

Yes. The two columns follow the page's direction, so the original is at the start; dates are wrapped so their digits stay in order, and the stars mirror. A right-to-left original would need its own lang and dir on its text.

  • Pro

    Masonry Layout Reviews

    Cards and walls

    Twelve reviews of pruning shears as cards of every length in CSS columns, with a star filter, an order switch, a polite count and a Helpful vote on each card.

  • Pro

    Split View Reviews

    Lists and pages

    A master and detail split for six monitor reviews: a list where each row is a checkbox, a pane that shows the one you tick in full, or two side by side with a 'Both mention' line, and arrow keys that move between rows.

  • Pro

    Timeline Feed Reviews

    Lists and pages

    Twelve reviews of a smart thermostat on a month-by-month timeline with each month's derived average and count, review cards on shared hairlines and a firmware filter.

  • Pro

    Twelve reviews of an interior paint as accordion rows: stars, title, excerpt and byline when closed; the whole review, a Helpful vote and the seller's reply when open.

  • Pro

    Helpful Votes Reviews

    Votes and replies

    The best favourable and the best critical review of a water filter jug side by side, each with a Helpful vote and a worked-out 'n of m found this helpful', above the other reviews in ruled rows with a most-helpful or newest order.

  • Pro

    Multi-Language FAQ

    Reading and sharing

    An FAQ in English, Spanish and Arabic for a relocation service: a language switcher swaps the title, questions and answers, and sets lang and dir so Arabic lays the block out from its end.