Widget integration
In this section, we will discuss the integration of each TradingView widget, with detailed instructions regarding code embedding and widget placement. Each widget provides different insights into a company or stock’s performance, and as such, they will each play a unique role on our web page.
Matching the widgets to your page design
All the widgets have two themes to choose from: ‘light’ and ‘dark’. In this tutorial, we will use the ‘light’ theme because it matches our existing page design, which has a white background color.
Integrating the Ticker Tape Widget
We’ll start by integrating the Ticker Tape widget into our webpage. The Ticker Tape gives a real-time representation of the performance of a group of symbols.
Head to the configurator for the Ticker Tape widget, customise the settings as you see fit and then copy the code to be embedded in the page.
Getting the widget into the page is as simple as copy-pasting the embed code inside the element on the page where you would like it to appear. In this case we want to insert the code inside this element:
<nav id="ticker-tape"></nav>which would end up looking like this:
<nav id="ticker-tape"> <!-- TradingView Widget BEGIN --> <div class="tradingview-widget-container"> <div class="tradingview-widget-container__widget"></div> <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-ticker-tape.js" async> { "symbols": [ { "description": "", "proName": "NASDAQ:TSLA" }, { "description": "", "proName": "NASDAQ:AAPL" }, { "description": "", "proName": "NASDAQ:NVDA" }, { "description": "", "proName": "NASDAQ:MSFT" }, { "description": "", "proName": "NASDAQ:AMZN" }, { "description": "", "proName": "NASDAQ:GOOGL" }, { "description": "", "proName": "NASDAQ:META" }, { "description": "", "proName": "NYSE:BRK.B" }, { "description": "", "proName": "NYSE:LLY" }, { "description": "", "proName": "NYSE:UNH" }, { "description": "", "proName": "NYSE:V" }, { "description": "", "proName": "NYSE:WMT" } ], "showSymbolLogo": true, "colorTheme": "light", "isTransparent": false, "displayMode": "adaptive", "locale": "en" } </script> </div> <!-- TradingView Widget END --></nav> " data-copied=Copied!>However, Ticker Tape is one of the widgets which doesn’t require this and will instead occupy enough height to display it’s contents automatically. So we can adjust the skeleton styles to remove the CSS manually setting a height for the #ticker-tape element.
.skeleton,#ticker-tape, /* ← remove this line*/#symbol-info,#advanced-chart,#company-profile,#fundamental-data,#technical-analysis,#top-stories,#ticker-tape { text-align: center; padding: 16px; font-size: 24px; background: rgba(0, 0, 0, 0.075); border-radius: 4px;}
#ticker-tape { width: 100%; margin-bottom: var(--gap-size); height: 75px; /* ← remove this line*/}This will remove the skeleton styling on that element and set height to the default of auto.
Integrating the Symbol Info Widget
Next, we will add the Symbol Info widget, which provides useful details related to a specific symbol. The widget displays key summary metrics for the symbol, including the current price and fundamental data such as the symbol’s market cap.
Symbol Info is another widget which doesn’t require a specific height to be set for the container and will instead automatically adjust it’s height to fit it’s content.
So adding the Symbol info widget follows the same steps as the Ticker Tape widget.
- Configure the widget on the Wizard page
- Grab the embed code
- paste it within the desired element on the page (
<section id="symbol-info"></section>) - and adjust the CSS to remove the skeleton styling and predefined height.
You should end up with the HTML element looking like this:
<section id="symbol-info"> <!-- TradingView Widget BEGIN --> <div class="tradingview-widget-container"> <div class="tradingview-widget-container__widget"></div> <script type="text/javascript" src="https://s3.tradingview.com/external-embedding/embed-widget-symbol-info.js" async> { "symbol": "NASDAQ:AAPL", "width": "100%", "locale": "en", "colorTheme": "light", "isTransparent": true } </script> </div> <!-- TradingView Widget END --></section> " data-copied=Copied!>