Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Regional Access Comments Block for Svelte

Six regions each set to Read and post, Read only or Blocked, with a visitor tester that states the outcome in words, marks the matching rule and previews the thread, a closed composer or an empty state.

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

Decide what each part of the world may do in a forum, and check it before you ship, with this regional access panel for Svelte with Ark UI. A compact header names the forum. A hairline frame lists six regions, each with three choices as native radio buttons: Read and post, Read only or Blocked, and a heading that counts how many are restricted. Under the rules a "Test a visitor" Native Select picks one of six typed visitors (documentation addresses such as 203.0.113.7, with a city and a country), and the block states the outcome in words ("Can read, cannot post"), marks the rule that matched and draws what that visitor would see in a preview of fixed height: the thread with an open composer, the thread with a Textarea and Button closed and the reason, or an Empty state that says "Not available in your region". A polite status line repeats the result after every change. It is built from Native Select, Textarea, Button, Empty, Badge, Label and Guides, with a CSS entrance only. For regional compliance, moderation tools and any forum with legal limits.

FAQ

How do I use my own regions and visitors?

Edit REGIONS, FIRST (the starting choice per region id) and VISITORS. A visitor has an address, a city, a country and the region id it belongs to; the matched rule, the outcome sentence and the preview are worked out from that and the current rules. The addresses are from the ranges reserved for documentation, so none belongs to anyone.

Does it look up a real location?

No. Nothing here checks an address or calls a network: the region of each visitor is typed. A real app resolves the visitor's region on the server, from a geolocation database kept up to date, and enforces the rule there for reading and for posting. Remember that addresses are an imperfect guide: shared networks, mobile carriers and VPNs all move people across borders, so give people a way to appeal and never treat a region as proof of anything.

Where should the rules be enforced?

On the server, for every request. A hidden composer in the browser stops no one. Check the rule when a thread is read (return a 451 or a plain empty response for Blocked) and when a comment is posted, and log the rule that matched so you can explain a decision.

Is it accessible?

Each region's choices are native radio buttons that share a name, so the arrow keys move inside a row and the choice is shown by a filled cell and the word, not colour. Each radio is also named with its region for screen readers. The matched row says "Matched", the preview explains why posting is closed in text, and the status line is present from load and is read out politely.

How does it look on a phone?

Each region becomes a row with its three choices under the name, in equal cells that fit at 320 pixels. The preview keeps the same height in every state, so changing a rule or a visitor never moves the page.