Skip to content

Previewbox Article

Our previewbox-article component is perfect for showing a preview of an article. Simply pass the URL of the article and we will fetch the data for you.

Demo

If you like to play around with the component, you can check out this CodePen demo.

To use the <previewbox-article> component, you can either set the href attribute to fetch article data automatically or manually set the attributes for a custom preview.

Automatically Fetched Data

html
<previewbox-article href="https://web-highlights.com"></previewbox-article>

Learn more about the automatic data fetching in our hosting guide.

Manually Set Data

html
<previewbox-article
  url="https://example.org"
  title="This Title Was Manually Passed"
  description="This description was manually passed. The data was not fetched from the URL because no href was provided."
  imageUrl="https://picsum.photos/1200/630"
  imageAlt="Lorem Ipsum Image"
></previewbox-article>

You can find all available properties in the API documentation.

Customize Read More Button Text

You can customize the read more button text by setting the readMoreBtnText attribute.

html
<previewbox-article
  readMoreBtnText="Custom Read More"
  href="https://web-highlights.com"
></previewbox-article>

Hide Read More Button

You can hide the read more button by setting the showReadMoreButton attribute to false.

html
<previewbox-article
  hideReadMoreBtn
  href="https://web-highlights.com"
></previewbox-article>

CSS Customization

The <previewbox-article> component supports CSS customization through custom properties. You can define these properties in your stylesheet or directly in the HTML using the style attribute. Here's an example:

html
<previewbox-article
  style="--pb-background-color: #595959; --pb-background-color-hover: #4a4a4a; --pb-text-color: white; --pb-text-color-light: #ffffff;"
  href="https://web-highlights.com/about"
></previewbox-article>

Learn more about this in our CSS Variables documentation.

CSS Custom Properties

The <previewbox-article> component supports the following CSS custom properties for styling:

Property NameDescriptionDefault Value
--pb-background-colorBackground color of the article card#ffffff
--pb-dark-background-colorBackground color in dark mode#121212
--pb-text-colorText color of the article card#000000
--pb-dark-text-colorText color in dark mode#e0e0e0
--pb-text-color-lightColor of the metadata text like description and authorrgba(0, 0, 0, 0.7)
--pb-dark-text-color-lightMetadata text color in dark modergba(255, 255, 255, 0.8)
--pb-border-colorBorder color of the article cardrgb(124 139 154 / 25%)
--pb-dark-border-colorBorder color in dark mode#8080803a
--pb-skeleton-colorColor of the loading skeletonrgb(229, 231, 235)
--pb-dark-skeleton-colorSkeleton color in dark modergb(55, 65, 81)
--pb-fallback-img-colorColor of the fallback imagehsl(220, 13%, 80%)
--pb-dark-fallback-img-colorFallback image color in dark modehsl(220, 13%, 40%)
--pb-fallback-img-backgroundBackground of the fallback imagergb(229, 231, 235)
--pb-dark-fallback-img-backgroundFallback image background in dark modergb(55, 65, 81)

These properties allow you to customize the appearance of the article preview to match your website's design.