Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentXPost
Managercreate_x_post_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { XPost, create_x_post_manager } from "sveltekit-ui"

  // The component loads X's widget script to embed this public post.

  const manager = create_x_post_manager({
    post_id: "20",
    is_dark_theme: false,
  })
</script>

<XPost {manager} />

API reference

Configure the manager, call its methods, and read its reactive state.

10 entries in configuration

PropertyTypeDefaultDescription
idstring or null generated unique IDA unique string ID for this XPost component. If not provided, a unique ID is generated automatically.
post_idstring nullThe unique identifier of the X (Twitter) post to embed. This is required for rendering the post.
hrefstring or null nullThe URL associated with the post. If it starts with '/', it's treated as an internal link; otherwise, as an external link.
display_textstring or null nullThe text to display for the link. If not provided, child content can be used instead.
text_colorCSS color or null nullThe color of the link text. If not specified, it inherits the default styling.
is_show_previewboolean !is_internal_linkDetermines whether to show a popover preview of the post when clicked. Defaults to true for external links and false for internal links.
is_dark_themeboolean trueIf true, the embedded post uses a dark theme. Otherwise, a light theme is applied.
heightnumber or null min(40rem, 50vh)The height of the popover containing the embedded post, specified in rem. Defaults to 'min(40rem, 50vh)' if not set.
widthnumber or null clamp(60rem, 80vw, 100%)The width of the popover containing the embedded post, specified in rem. Defaults to 'clamp(60rem, 80vw, 100%)' if not set.
on_goto_external_linkfunction or null nullOptional callback function that is invoked when an external link is opened. Receives the `href` as an argument.