Skip to content
Create account
or
Sign in
The Stripe Docs logo
/
Ask AI
Create account
Sign in
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Developer tools
Get started
Payments
Finance automation
Get started
Payments
Finance automation
Platforms and marketplaces
Money management
Overview
Versioning
Changelog
Upgrade your API version
Upgrade your SDK version
Developer tools
SDKs
API
Testing
Workbench
Event Destinations
Workflows
Stripe CLI
Stripe Shell
Developers Dashboard
Agent toolkit
Build with LLMsStripe for Visual Studio CodeStripe health alertsFile uploads
Security and privacy
Security
Extend Stripe
Stripe Apps
    Overview
    Get started
    Create an app
    How Stripe Apps work
    Sample apps
    Build an app
    Store secrets
    API authentication methods
    Authorization flows
    Server-side logic
    Listen to events
    Handle different modes
    Enable sandbox support
    App settings page
    Build a UI
    Onboarding
    Distribute your app
    Distribution options
    Upload your app
    Versions and releases
    Test your app
    Publish your app
    Promote your app
    Add deep links
    Create install links
    Assign roles in UI extensions
    Post-install actions
    App analytics
    Embedded components for Apps
    Embed third-party Stripe Apps
    Migrating to Stripe Apps
    Migrate or build an extension
    Migrate a plugin to Stripe Apps or Stripe Connect
    Reference
    App manifest
    CLI
    Extension SDK
    Permissions
    Viewports
    Design patterns
    Components
      Accordion
      Badge
      Banner
      BarChart
      Box
      Button
      ButtonGroup
      Checkbox
      Chip
      ContextView
      DateField
      Divider
      FocusView
      FormFieldGroup
      Icon
      Img
      Inline
      LineChart
      Link
      List
      Menu
      PropertyList
      Radio
      Select
      SettingsView
      SignInView
      Sparkline
      Spinner
      Switch
      Table
      Tabs
      Tasklist
      TextArea
      TextField
      Toast
      Tooltip
Stripe Connectors
Partners
Partner ecosystem
Partner certification
HomeDeveloper toolsStripe AppsComponents

Img component for Stripe Apps

Display images with the Img UI component.

Copy page

To add an image to your app:

  1. Import the Img component:
import {Img} from '@stripe/ui-extension-sdk/ui';
  1. Include the base URLs of any images you include in the image-src section of the content_security_policy in your app manifest.

The following shows a preview of an image with the respective Img tag below:

Loading example...
<Img src="https://images.example.com/gross-volume.svg" width="484" height="207" alt="Gross volume" />

Img props

PropertyType

alt

Optional

string | undefined

The alternative text of the image.

crossOrigin

Optional

"anonymous" | undefined

Cross-origin support for the image.

height

Optional

(string | number) | undefined

The height of the image.

sizes

Optional

string | undefined

The sizes of the image (for use with srcSet).

src

Optional

string | undefined

The source of the image.

srcSet

Optional

string | undefined

The source set of the image.

width

Optional

(string | number) | undefined

The width of the image.

SrcSet

You can use srcSet for responsive images.

The example below uses the size attribute to define the maximum width of the specified image:

Loading example...
<Img srcSet="https://images.example.com/daily-sales.jpg 480w, https://images.example.com/daily-sales-large.jpg 800w" sizes="(max-width: 600px) 480px, 800px" width="484" height="207" alt="Daily sales" />

Data URLs

You can co-locate images with your UI extension code and load them directly into the Img component. Supported formats are GIF, JPEG, SVG, PNG, and WEBP.

We recommend using SVG for most common use-cases like icons and other way finding illustrations. You must include the suffix of the image in the require or import statement.

Loading example...
import {Img} from '@stripe/ui-extension-sdk/ui'; import CommunityIcon from './community-icon.svg'; const DataURl = () => ( <Img width="75" height="75" src={CommunityIcon} alt="Community" /> )

Styling

You can achieve certain styling effects for Img components by wrapping them with a styled Box component.

Borders

To add a border to an Img, use the CSS keyline property, along with width and display to contain the image:

Loading example...
<Box css={{ keyline: 'critical', width: 'fit', stack: 'x', }} > <Img src="https://images.example.com/gross-margin.svg" width="484" height="207" alt="Gross margin" /> </Box>

Rounded corners

To add rounded corners to an Img, use the CSS borderRadius property, along with overflow, width, and display to contain the image:

Loading example...
<Box css={{ borderRadius: 'rounded', overflow: 'hidden', width: 'fit', stack: 'x', }} > <Img src="https://images.example.com/gross-margin.svg" width="484" height="207" alt="Gross margin" /> </Box>

See also

  • Design patterns to follow
  • Style your app
  • UI testing
Was this page helpful?
YesNo
Need help? Contact Support.
Join our early access program.
Check out our changelog.
Questions? Contact Sales.
LLM? Read llms.txt.
Powered by Markdoc