X Post
tool-ui/x-postFreeBlock
Render X (Twitter) post previews.
See it running
Open the demo on tool-ui
www.tool-ui.com/components/x-postInstall it
npx shadcn@latest add https://www.tool-ui.com/r/x-post.jsonSource
1"use client";23import * as React from "react";4import { Heart, Share } from "lucide-react";5import {6 cn,7 Button,8 Tooltip,9 TooltipContent,10 TooltipProvider,11 TooltipTrigger,12} from "./_adapter";13import { formatCount, formatRelativeTime, getDomain } from "../shared/utils";1415import { resolveSafeNavigationHref } from "../shared/media";16import type { XPostData, XPostMedia, XPostLinkPreview } from "./schema";1718export interface XPostProps {19 post: XPostData;20 className?: string;21 onAction?: (action: string, post: XPostData) => void;22}2324function Avatar({ src, alt }: { src: string; alt: string }) {25 return (26 <img27 src={src}28 alt={alt}29 width={40}30 height={40}31 className="size-10 shrink-0 rounded-full object-cover"32 />33 );34}3536function XLogo({ className }: { className?: string }) {37 return (38 <svg39 viewBox="0 0 300 271"40 className={className}41 role="img"42 aria-label="X (formerly Twitter) logo"43 >44 <path45 fill="currentColor"46 d="m236 0h46l-101 115 118 156h-92.6l-72.5-94.8-83 94.8h-46l107-123-113-148h94.9l65.5 86.6zm-16.1 244h25.5l-165-218h-27.4z"47 />48 </svg>49 );50}5152function VerifiedBadge({ className }: { className?: string }) {53 return (54 <svg55 viewBox="0 0 24 24"56 className={className}57 role="img"58 aria-label="Verified account"59 >60 <path61 fill="currentColor"62 d="M22.5 12.5c0-1.58-.875-2.95-2.148-3.6.154-.435.238-.905.238-1.4 0-2.21-1.71-3.998-3.818-3.998-.47 0-.92.084-1.336.25C14.818 2.415 13.51 1.5 12 1.5s-2.816.917-3.437 2.25c-.415-.165-.866-.25-1.336-.25-2.11 0-3.818 1.79-3.818 4 0 .495.083.965.238 1.4-1.272.65-2.147 2.018-2.147 3.6 0 1.495.782 2.798 1.942 3.486-.02.17-.032.34-.032.514 0 2.21 1.708 4 3.818 4 .47 0 .92-.086 1.335-.25.62 1.334 1.926 2.25 3.437 2.25 1.512 0 2.818-.916 3.437-2.25.415.163.865.248 1.336.248 2.11 0 3.818-1.79 3.818-4 0-.174-.012-.344-.033-.513 1.158-.687 1.943-1.99 1.943-3.484zm-6.616-3.334l-4.334 6.5c-.145.217-.382.334-.625.334-.143 0-.288-.04-.416-.126l-.115-.094-2.415-2.415c-.293-.293-.293-.768 0-1.06s.768-.294 1.06 0l1.77 1.767 3.825-5.74c.23-.345.696-.436 1.04-.207.346.23.44.696.21 1.04z"63 />64 </svg>65 );66}6768function AuthorInfo({69 name,70 handle,71 verified,72 createdAt,73}: {74 name: string;75 handle: string;76 verified?: boolean;77 createdAt?: string;78}) {79 return (80 <div className="flex min-w-0 items-center gap-1">81// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from tool-ui
All 27 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Approval Cardapproval-card | tool-ui | Blocks | Free | 2 deps · 11 files | |
| Audioaudio | tool-ui | Blocks | Free | 2 deps · 9 files | |
| Chartchart | tool-ui | Blocks | Free | 2 deps · 8 files | |
| Citationcitation | tool-ui | Blocks | Free | 2 deps · 15 files | |
| Code Blockcode-block | tool-ui | Blocks | Free | 3 deps · 11 files | |
| Code Diffcode-diff | tool-ui | Blocks | Free | 3 deps · 10 files | |
| Data Tabledata-table | tool-ui | Blocks | Free | 1 dep · 17 files | |
| Geo Mapgeo-map | tool-ui | Blocks | Free | 4 deps · 12 files |
